package com.homwee.factory.tvtool;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

//import org.apache.http.util.EncodingUtils;

import com.homwee.factory.R;
import com.mediatek.twoworlds.factory.MtkTvFApiSystem;
import com.mediatek.twoworlds.factory.MtkTvFApiDisplay;
import com.mediatek.twoworlds.factory.MtkTvFApiDisplayTest;
import com.mediatek.twoworlds.factory.MtkTvFApiInformation;
import com.mediatek.twoworlds.factory.MtkTvFApiInputSource;
import com.mediatek.twoworlds.factory.common.MtkTvFApiDisplayTypes.ColorTempData;
import com.mediatek.twoworlds.factory.common.MtkTvFApiDisplayTypes.EnumInputSourceType;
import com.mediatek.twoworlds.factory.common.MtkTvFApiDisplayTypes.NonLinearPqCurve;
import com.mediatek.twoworlds.factory.common.MtkTvFApiDisplayTypes.NonLinearPqType;
import com.mediatek.twoworlds.factory.common.inimanager.MtkTvFApiDisplayIniManager;
import com.mediatek.twoworlds.factory.model.MtkTvFApiInpsrcEnm;
import com.mediatek.twoworlds.tv.MtkTvConfig;
import com.mediatek.twoworlds.tv.MtkTvInputSource;
import com.mediatek.twoworlds.tv.MtkTvInputSourceBase;
import com.mediatek.twoworlds.tv.common.MtkTvConfigType;
import com.mediatek.twoworlds.tv.common.MtkTvConfigTypeBase;
import com.mediatek.twoworlds.factory.common.MtkTvFApiResultTypeBase;
import com.mediatek.twoworlds.factory.clientwrapper.MtkTvFApiInformationWrapper;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog; 
import android.content.DialogInterface;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.graphics.drawable.ColorDrawable;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
import android.net.Uri;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Bundle;
import android.os.storage.StorageManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity; 
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.Spinner;
import com.mediatek.twoworlds.factory.common.MtkTvFApiDisplayTypes.EnumColorTemperature;

import com.homwee.factory.tvtool.INIStructure;
import com.homwee.factory.tvtool.FlowRadioGroup;
import com.homwee.factory.tvtool.StaticValues;
import com.homwee.factory.TvToolService;
import com.homwee.factory.util.Contants;

//import com.changhong.dm.DeviceManager;
//import com.changhong.dm.MountPoint;
//import com.changhong.tvos.common.TVManager;
//import com.changhong.tvos.common.exception.IllegalValueException;
//import com.changhong.tvos.common.exception.TVManagerNotInitException;
//import com.changhong.tvos.model.ChOsType.ENUMColorTempMode;
//import com.changhong.tvos.model.ChOsType.ENUMPictureMode;
//import com.changhong.tvos.model.ChOsType.EnumPanelType;
//import com.changhong.tvos.model.ChOsType.EnumPipInputSource;
//import com.changhong.tvos.model.EnumInputSource;
//import com.changhong.tvos.model.EnumResource;
//import com.changhong.tvos.model.PanelInfo;

public class NewPQActivity extends Activity {
	WindowManager mWindowManager; 
	LayoutInflater mInflater;
	private long mExitTime;
	WindowManager.LayoutParams mParams;
	PQLayout_Main mLayout_main;
	LinearLayout mLayout_linear, mLayout_color, mLayout_gamma, mLayout_linear_benq;
	String mVersionNumber="V0.00";// version number
	String mScrollString1, mScrollString2;
	int MAX_STRING_LENGTH = 13;
	int scrollIndex = 0;
	int mStepSize = 1;// Image analog adjustment step
	WindowPosition mWindowPosition = WindowPosition.WP_TOP_LEFT;// Debug menu display location
	public final static int BORDER_GAP    = 50;
	String mPanelModel, mLocalPath, mSdcardPath;
	INIStructure mStructure;
	boolean bVirginLinear = true;
	boolean bVirginColor = true;
	boolean bVirginGamma = true;
	static String TAG = "TVtool";
	public static Handler handler;
	Timer timer;
	TimerTask timerTask;
	boolean bOnCreate = true;
	ArrayList<PQLayout_Message> messages = new ArrayList<PQLayout_Message>();
	private ArrayList<MtkTvInputSourceBase.InputSourceRecord> inputList = new ArrayList<MtkTvInputSourceBase.InputSourceRecord>();
	private String HDMI1Uri = "content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW4";
	private String ComponentUri = "content://android.media.tv/passthrough/com.mediatek.tvinput%2F.component.ComponentInputService%2FHW2";
	private String CompositeUri = "content://android.media.tv/passthrough/com.mediatek.tvinput%2F.composite.CompositeInputService%2FHW1";
	private String VgaUri = "content://android.media.tv/passthrough/com.mediatek.tvinput%2F.vga.VGAInputService%2FHW3";
	private String TVUri = "content://android.media.tv/channel";
	private String HDMI2Uri = "content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW5";
	private String HDMI3Uri = "content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW6";
	private Map<String, String> sourceMap = new HashMap<String, String>();
	private ArrayList<String> mUiSourceList = new ArrayList<String>();
	private String[] SourceName ;
	public static Context mContext = null;
	
	private boolean needShopValue = true;
	private int inputSrcType;
	private int clortempindex;
	private EnumInputSourceType curSourceType;
	
	//shougang.lin add modify 2014.07.08 next 3 line
	//Environment.getExternalStorageDirectory().getPath();
	
    //DeviceManager mDeviceManager = DeviceManager.getInstance();
    //ArrayList<MountPoint> deviceLabel = mDeviceManager.getMountPointList(); 
    
	String SDPath;//=Environment.getExternalStorageDirectory().getPath();
	int[] maxValue = {255,255,255,63,100}; 
	ColorTempData mcolortempdata ;
	private int colortempMax = 1524;
	private int colortempMin = 524;

	enum WindowPosition {
		WP_CENTER, WP_TOP_LEFT, WP_TOP_RIGHT, WP_BOTTOM_RIGHT, WP_BOTTOM_LEFT;

		public static WindowPosition getNext(WindowPosition pos) {

			switch (pos) {
			case WP_CENTER:
				return WP_TOP_LEFT;
			case WP_TOP_LEFT:
				return WP_TOP_RIGHT;
			case WP_TOP_RIGHT:
				return WP_BOTTOM_RIGHT;
			case WP_BOTTOM_RIGHT:
				return WP_BOTTOM_LEFT;
			case WP_BOTTOM_LEFT:
				return WP_CENTER;
			default:
				return WP_CENTER;
			}
		}

		public static WindowPosition getPrev(WindowPosition pos) {

			switch (pos) {
			case WP_CENTER:
				return WP_BOTTOM_LEFT;
			case WP_BOTTOM_LEFT:
				return WP_BOTTOM_RIGHT;
			case WP_BOTTOM_RIGHT:
				return WP_TOP_RIGHT;
			case WP_TOP_RIGHT:
				return WP_TOP_LEFT;
			case WP_TOP_LEFT:
				return WP_CENTER;
			default:
				return WP_CENTER;
			}
		}

	}

	String[] WINDOW_POSITION_NAMES = { "◀ Center ▶", "◀ On the left ▶", "◀ On the right ▶", "◀ lower right▶",
			"◀ lower left ▶" };




	
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
//		getApplication();
		mContext = this;
		initSourceName();
		curSourceType = getCurrentInputSourceType();
		int totalSource = MtkTvInputSource.getInstance().getInputSourceTotalNumber();
		SourceName = new String[totalSource];
		for(int i = 0; i < totalSource; i++){
		    SourceName[i] = mUiSourceList.get(i);
//		    Log.d(TAG,"source name "+record.getSourceName()+" sourceid "+record.getId());
		}
		if(!mUiSourceList.contains("ATV")){
			mUiSourceList.set(0, "TV");
			sourceMap.put("TV", TVUri);
			SourceName[0]="TV";
		}
		
//		for(int i = 0; i < totalSource; i++){
//		    MtkTvInputSourceBase.InputSourceRecord record = new MtkTvInputSourceBase.InputSourceRecord();
//		    MtkTvInputSource.getInstance().getInputSourceRecbyidx(i, record);
//		    inputList.add(record);
//		}
		mWindowManager = (WindowManager) mContext.getSystemService(
				Context.WINDOW_SERVICE);
		mInflater = LayoutInflater.from(mContext);
		
		
		
		
		//usb path
//		UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);  
//		HashMap<String, UsbDevice> deviceList = manager.getDeviceList();  
//		Log.e(TAG, "get device list  = " + deviceList.size());  
//		Toast.makeText(this, "get device list  = " + deviceList.size(), 200).show();  
//		Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();  
//		while (deviceIterator.hasNext()) {  
//		     UsbDevice device = deviceIterator.next();  
//		     Log.e(TAG, "device name = " + device.getDeviceName());  
//		}
		
		//StorageManager mStorageManager = (StorageManager) this.mContext.getSystemService(Context.STORAGE_SERVICE);
		//StorageVolume[] mStorageVolume = storageManager.getVolumeList();
		//getPrimaryStoragePath();
		
		
        // Log.i(TAG,SDPath);
		//Verify that the U disk is inserted and get the U disk path.
		CheckSDCardSwitchOn();
		
		//Gets the current screen reference name, and then combines the path to the quality file   /hwcfg/pq/$PANEL_NAME/$(PANEL_NAME)_pq.ini
		getPanelModelAndSetFileNameAndPath();

		//Initialize the INI file and assign it with the default value
		initINIStructure();
		
		//Reads the current quality INI file and overrides the default with the actual value.
		//boolean bFileAbsence = false;
		if (new File(mLocalPath).exists()) {
//			if(SystemProperties.get("ro.product.brand", "CHANGHONG").equalsIgnoreCase("BenQ")){
//				readIniFileBenq(mLocalPath);
//			} else {
			    readIniFile(mLocalPath);
//			}
		} else {
//			AlertIniFileAbsence();	//Error hint, default value will be used
		}

		//Define display interfaces
		mLayout_main = new PQLayout_Main(mContext);//Main interface
		mLayout_linear = new PQLayout_Linear(mContext);//Linear adjustment interface
		mLayout_color = new PQLayout_Color(mContext);//Color temperature adjustment interface
//		mLayout_gamma = new PQLayout_Gamma(mContext);//GAMMA Adjusting interface
		mParams = getWindowManagerParams(mWindowPosition);// Position offset interface
		mWindowManager.addView(mLayout_main, mParams);
		
		bOnCreate = false;
		
		for(PQLayout_Message layout : messages)
		{
			layout.show();
		}
		
	}//creat over.
	
	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
		// factorySystemManager.removeUartColorTempNotifyLisenter(notifyLisenter);
	}


	//Gets the screen name and gets the quality path
	private void getPanelModelAndSetFileNameAndPath() {
		// TODO Auto-generated method stub
		mPanelModel = getPanelModel();
		if (mLayout_main != null) {
			mLayout_main.set_et_panelModel_text(mPanelModel);
		}
		mLocalPath = "/hwcfg/pq/" + mPanelModel + "/" + mPanelModel
				+ "_pq.ini";
		mSdcardPath = SDPath + "/"
				+ mPanelModel + "_pq.ini";
		
		
	}

	//Get screen name
	public String getPanelModel() {// Screen type
		// TODO Auto-generated method stub
		String panelName;
		try {
			//less of MTK
			String tempString = MtkTvFApiDisplay.getInstance().getPanelIni();
		    if (tempString != null || !tempString.isEmpty()) {
		    	panelName = tempString.substring(tempString.lastIndexOf("/") + 1,
		                tempString.lastIndexOf("."));
		    } else {
		    	panelName = MtkTvFApiDisplayIniManager.getInstance().getKey(MtkTvFApiDisplayIniManager.MTKTV_FAPI_KEY_TYPE_DISPLAY_ENUM.E_MTK_FAPI_KEY_TYPE_PANEL_NAME.ordinal());
		    }
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			showMessage("fail", "Failed to get screen model", true);
			panelName = "unknown";
		}
		return panelName;
	}

	//Memory global structure, initialized with default values
	private void initINIStructure() {
		// TODO Auto-generated method stub
		mStructure = new INIStructure();
		String[] curSection;
		for (int i = 0; i < SECTION_NAMES.length; i++) {
			mStructure.addSection(SECTION_NAMES[i]);
			curSection = getKeyNames(SECTION_NAMES[i]);
			for (int j = 0; j < curSection.length; j++) {
				mStructure.setValue(SECTION_NAMES[i], curSection[j], "");
			}
		}
		setDefaultValues();
	}

	//ini File parsing failed prompt  
	private void AlertIniFileAbsence() {
		// TODO Auto-generated method stub
		showMessage("Prompt", "PQ file missing！Default values will be used", true);
	}

	private void exportcolortemp() {
		if(SDPath == null || SDPath.isEmpty()) {
    		Toast.makeText(mContext, "U disk not found!!!", Toast.LENGTH_LONG).show();
    	}else {
//    		String localIniFilePath = "/vendor/cusdata/apollo/common/misc/OsdMapping.ini";
    		String localIniFilePath = Contants.FACTORY_TVTOOLS_OSDMAPPINGPATH;
    		String sdcardIniFilePath = SDPath + "/pq_export/OsdMapping.ini";
    		String PQExportPath = SDPath + "/pq_export";
    		if(!MtkTvFApiSystem.getInstance().isFolderExist(PQExportPath)) {
    			MtkTvFApiSystem.getInstance().createFolder(PQExportPath);
    		}
    		int ret = MtkTvFApiSystem.getInstance().copyFile(localIniFilePath,
        			sdcardIniFilePath,
    				 false);
    		if(ret == 0) {
    			updateOSDMappingformat();
        	    Toast.makeText(mContext, "export successed!", Toast.LENGTH_LONG)
        			.show();
            }
    	}
		
	}
	private void exportlinear() {
		if(SDPath == null || SDPath.isEmpty()) {
    		Toast.makeText(mContext, "U disk not found!!!", Toast.LENGTH_LONG).show();
    	}else {
//    		String localIniFilePath = "/vendor/tvconfig/config/PQ_general/NLA.ini";
    		String localIniFilePath = Contants.FACTORY_TVTOOLS_NLAPATH;
    		String sdcardIniFilePath = SDPath + "/pq_export/NLA.ini";
    		String PQExportPath = SDPath + "/pq_export";
    		if(!MtkTvFApiSystem.getInstance().isFolderExist(PQExportPath)) {
    			MtkTvFApiSystem.getInstance().createFolder(PQExportPath);
    		}
    		int ret = MtkTvFApiSystem.getInstance().copyFile(localIniFilePath,
        			sdcardIniFilePath,
        			false);
    		if(ret == 0) {
    			updateDLAformat();
        	    Toast.makeText(mContext, "export successed!", Toast.LENGTH_LONG)
        			.show();
            }
    	}
		
	}
	
	protected int updateOSDMappingformat(){
		String sdcardIniFilePath = SDPath + "/pq_export/OsdMapping.ini";
		int ret = MtkTvFApiResultTypeBase.MTKTV_FAPI_RET_OK;
		String IniPath = sdcardIniFilePath;
		ret = MtkTvFApiInformationWrapper.getInstance().openIniFile(IniPath);
        if( ret != MtkTvFApiResultTypeBase.MTKTV_FAPI_RET_OK )
        {
        	Log.v(TAG, "openIniFile Fail, result = " + ret);
            return ret;
        }
        int iniDataSize = 30;
        String Key =  MtkTvFApiDisplayIniManager.getInstance().getKey(MtkTvFApiDisplayIniManager.MTKTV_FAPI_KEY_TYPE_DISPLAY_ENUM.E_MTK_FAPI_KEY_TYPE_ATV_COLOR_TEMP_USER_RED_GAIN.ordinal());
		for(int keyIndex = MtkTvFApiDisplayIniManager.MTKTV_FAPI_KEY_TYPE_DISPLAY_ENUM.E_MTK_FAPI_KEY_TYPE_ATV_COLOR_TEMP_USER_RED_GAIN.ordinal();
				keyIndex < (MtkTvFApiDisplayIniManager.MTKTV_FAPI_KEY_TYPE_DISPLAY_ENUM.E_MTK_FAPI_KEY_TYPE_MMP_IMG_COLOR_TUNER_BLUE_OFFSET_HLG.ordinal() + 1);
				keyIndex++) {
			Key =  MtkTvFApiDisplayIniManager.getInstance().getKey(keyIndex);
//			String pqCurveFromIni =  MtkTvFApiDisplayIniManager.getInstance().getData(MtkTvFApiDisplayIniManager.MTKTV_FAPI_INI_TYPE_DISPLAY_ENUM.E_MTK_FAPI_INI_TYPE_NLA.ordinal(), keyIndex);
			String WBCurveFromIni = MtkTvFApiInformationWrapper.getInstance().readIniFile(Key);
	        String []data = new String[iniDataSize];
	        String []split_line = WBCurveFromIni.split(",");
	        int index = 0;
	        for (String s: split_line) {
	            data[index++] = s;
	            if(index > iniDataSize - 1) {
	            	Log.v(TAG, "Overflow");
	            	MtkTvFApiInformationWrapper.getInstance().saveIniFile(IniPath);
	            	return MtkTvFApiResultTypeBase.MTKTV_FAPI_RET_FAIL;
	            }
	        }


	        String setIniData = "";
	        int i;
	        for (i = 0; i < index; i++) {
	        	if(i==0) {
	        		setIniData += ("\\\n"+data[i]+",");
	        	}else if(i == index -1 ) {
	                setIniData += (data[i]+";");
	            }else if((i+1)%3 == 0){
	            	setIniData += (data[i]+",\\\n");
	            }else
	                setIniData += (data[i]+",");
	        }
//	        ret = MtkTvFApiDisplayIniManager.getInstance().setData(MtkTvFApiDisplayIniManager.MTKTV_FAPI_INI_TYPE_DISPLAY_ENUM.E_MTK_FAPI_INI_TYPE_NLA.ordinal(), keyIndex, setIniData);
	       ret = MtkTvFApiInformationWrapper.getInstance().writeIniFile(Key, setIniData);
	        
	        if( ret != MtkTvFApiResultTypeBase.MTKTV_FAPI_RET_OK )
	        {
	        	Log.v(TAG, "writeIniFile Fail, result = " + ret);
	        	return MtkTvFApiResultTypeBase.MTKTV_FAPI_RET_FAIL;
	        }
		}
		ret = MtkTvFApiInformationWrapper.getInstance().saveIniFile(IniPath);
		 Log.v(TAG, "updateformat, result = " + ret);

	    return ret;
	}

	
	protected int updateDLAformat(){
		String sdcardIniFilePath = SDPath + "/pq_export/NLA.ini";
		int ret = MtkTvFApiResultTypeBase.MTKTV_FAPI_RET_OK;
		String IniPath = sdcardIniFilePath;
		ret = MtkTvFApiInformationWrapper.getInstance().openIniFile(IniPath);
        if( ret != MtkTvFApiResultTypeBase.MTKTV_FAPI_RET_OK )
        {
        	Log.v(TAG, "openIniFile Fail, result = " + ret);
            return ret;
        }
        int iniDataSize = 100;
        String Key =  MtkTvFApiDisplayIniManager.getInstance().getKey(MtkTvFApiDisplayIniManager.MTKTV_FAPI_KEY_TYPE_DISPLAY_ENUM.E_MTK_FAPI_KEY_TYPE_CVBS_NON_LINEAR_CURVE.ordinal());
		for(int keyIndex = MtkTvFApiDisplayIniManager.MTKTV_FAPI_KEY_TYPE_DISPLAY_ENUM.E_MTK_FAPI_KEY_TYPE_CVBS_NON_LINEAR_CURVE.ordinal();
				keyIndex < (MtkTvFApiDisplayIniManager.MTKTV_FAPI_KEY_TYPE_DISPLAY_ENUM.E_MTK_FAPI_KEY_TYPE_OTHERS_NON_LINEAR_CURVE.ordinal() + 1);
				keyIndex++) {
			Key =  MtkTvFApiDisplayIniManager.getInstance().getKey(keyIndex);
//			String pqCurveFromIni =  MtkTvFApiDisplayIniManager.getInstance().getData(MtkTvFApiDisplayIniManager.MTKTV_FAPI_INI_TYPE_DISPLAY_ENUM.E_MTK_FAPI_INI_TYPE_NLA.ordinal(), keyIndex);
			String pqCurveFromIni = MtkTvFApiInformationWrapper.getInstance().readIniFile(Key);
	        String []data = new String[iniDataSize];
	        String []split_line = pqCurveFromIni.split(",");
	        int index = 0;
	        for (String s: split_line) {
	            data[index++] = s;
	            if(index > iniDataSize - 1) {
	            	Log.v(TAG, "Overflow");
	            	MtkTvFApiInformationWrapper.getInstance().saveIniFile(IniPath);
	            	return MtkTvFApiResultTypeBase.MTKTV_FAPI_RET_FAIL;
	            }
	        }


	        String setIniData = "";
	        int i;
	        for (i = 0; i < index; i++) {
	        	if(i==0) {
	        		setIniData += ("\\\n"+data[i]+",");
	        	}else if(i == index -1 ) {
	                setIniData += (data[i]+";");
	            }else if((i+1)%5 == 0){
	            	setIniData += (data[i]+",\\\n");
	            }else
	                setIniData += (data[i]+",");
	        }
//	        ret = MtkTvFApiDisplayIniManager.getInstance().setData(MtkTvFApiDisplayIniManager.MTKTV_FAPI_INI_TYPE_DISPLAY_ENUM.E_MTK_FAPI_INI_TYPE_NLA.ordinal(), keyIndex, setIniData);
	       ret = MtkTvFApiInformationWrapper.getInstance().writeIniFile(Key, setIniData);
	        
	        if( ret != MtkTvFApiResultTypeBase.MTKTV_FAPI_RET_OK )
	        {
	        	Log.v(TAG, "writeIniFile Fail, result = " + ret);
	        	return MtkTvFApiResultTypeBase.MTKTV_FAPI_RET_FAIL;
	        }
		}
		ret = MtkTvFApiInformationWrapper.getInstance().saveIniFile(IniPath);
		 Log.v(TAG, "updateformat, result = " + ret);

	    return ret;
	}

	//Save all exports and save from memory to this machine. If you have a U disk, save it from memory to the U disk.
	private void saveAndExport() {

		getPanelModelAndSetFileNameAndPath();
		int saveret = MtkTvFApiDisplay.getInstance().saveDisplayIni();
//		boolean bLocal=saveToLocal();
		if(saveret == 0){
			showMessage("Success", "●Save data to native successfully！\n\n", true);
		}else{
			showMessage("Fail", "●Data saved to native failed！\n\n", true);
		}	
		
//		boolean bUpath=(CheckSDCardSwitchOn()&&saveToSDCard());
//		if(bUpath){
//			showMessage("Success", "●Data export to U disk success！\n\n", true);
//		}else{
//			showMessage("Fail", "●The data exported to the U disk failed！\n\n", true);
//		}	
		
		
//		boolean bLocal=saveToLocal();
//		if (CheckSDCardSwitchOn()) {		
//				boolean bUpath=saveToSDCard();
//				if (bLocal && bUpath) {
//					showMessage("结果", "●保存本机和导出都成功!!!\n\n" + "●保存本机路径：" + mLocalPath + "\n"
//							+ "●导出U盘路径：" + mSdcardPath, true);
//				} else {
//					if(bLocal || bUpath)
//					{
//						if(bLocal) showMessage("结果", "●保存本机成功！\n\n"+ "保存本机路径：" + mLocalPath, true);
//						if(bUpath) showMessage("结果", "●U盘导出成功！\n\n"+ "导出U盘路径：" + mSdcardPath, true);
//					}
//					else
//					{	
//					     showMessage("结果", "●保存本机失败！！！"+ "保存路径：" + mLocalPath + "\n"+"U盘导出失败！\n"+ "导出U盘路径：" + mSdcardPath, true);
//					}
//				}
//		} else {
//			if (bLocal) {
//				showMessage("", "●保存本机成功。\n" + "保存路径：" + mLocalPath + "\n"+ "未检测到U盘，不能导出！", true);
//			} else {
//				showMessage("", "●保存本机失败！！！\n"+"未检测到U盘，不能导出！", true);
//			}
//		}

	}
	
	//Save all exports and save from memory to this machine. If you have a U disk, save it from memory to the U disk.
		private void saveAndExportBenq() {

			getPanelModelAndSetFileNameAndPath();
			boolean bLocal=saveToLocalBenq();
			if(bLocal){
				showMessage("Success", "●Save data to native successfully！\n\n", true);
			}else{
				showMessage("Fail", "●Data saved to native failed！\n\n", true);
			}	
			
			boolean bUpath=(CheckSDCardSwitchOn()&&saveToSDCardBenq());
			if(bUpath){
				showMessage("Success", "●Data export to U disk success！\n\n", true);
			}else{
				showMessage("Fail", "●The data exported to the U disk failed！\n\n", true);
			}	
			
			
//			boolean bLocal=saveToLocal();
//			if (CheckSDCardSwitchOn()) {		
//					boolean bUpath=saveToSDCard();
//					if (bLocal && bUpath) {
//						showMessage("结果", "●保存本机和导出都成功!!!\n\n" + "●保存本机路径：" + mLocalPath + "\n"
//								+ "●导出U盘路径：" + mSdcardPath, true);
//					} else {
//						if(bLocal || bUpath)
//						{
//							if(bLocal) showMessage("结果", "●保存本机成功！\n\n"+ "保存本机路径：" + mLocalPath, true);
//							if(bUpath) showMessage("结果", "●U盘导出成功！\n\n"+ "导出U盘路径：" + mSdcardPath, true);
//						}
//						else
//						{	
//						     showMessage("结果", "●保存本机失败！！！"+ "保存路径：" + mLocalPath + "\n"+"U盘导出失败！\n"+ "导出U盘路径：" + mSdcardPath, true);
//						}
//					}
//			} else {
//				if (bLocal) {
//					showMessage("", "●保存本机成功。\n" + "保存路径：" + mLocalPath + "\n"+ "未检测到U盘，不能导出！", true);
//				} else {
//					showMessage("", "●保存本机失败！！！\n"+"未检测到U盘，不能导出！", true);
//				}
//			}

		}
    
	//Save the memory structure directly to the U disk
	private boolean saveToSDCard() {
		// TODO Auto-generated method stub
		INIFile iniFile = new INIFile("PQ", mPanelModel);
		String[] curSection;
		if(needShopValue == true){
		for (int i = 0; i < SECTION_NAMES.length; i++) {
			curSection = getKeyNames(SECTION_NAMES[i]);
			for (int j = 0; j < curSection.length; j++) {
				iniFile.SetValue(SECTION_NAMES[i], curSection[j],
						mStructure.getValue(SECTION_NAMES[i], curSection[j]));
			}
		}
		} else {
			for (int i = 0; i < SECTION_NAMES.length - 2; i++) {
				curSection = getKeyNames(SECTION_NAMES[i]);
				for (int j = 0; j < curSection.length; j++) {
					iniFile.SetValue(SECTION_NAMES[i], curSection[j],
							mStructure.getValue(SECTION_NAMES[i], curSection[j]));
				}
			}
		}

		boolean bCloseRet = iniFile.closeINI(mSdcardPath);
		try {
			Runtime.getRuntime().exec("sync");
			Runtime.getRuntime().exec("sync");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			showMessage(getString(R.string.pq_sync_error), getString(R.string.pq_sync_out_error), true);
		}
		if (bCloseRet) {
			return true;// showMessage("", "Export to U disk successfully \n" + mSdcardPath, true);
		} else {
			return false;// showMessage("", "Export to U disk failed！！！ \n", true);
		}

	}
	
	//Save the memory structure directly to the U disk
		private boolean saveToSDCardBenq() {
			// TODO Auto-generated method stub
			INIFile iniFile = new INIFile("PQ", mPanelModel);
			String[] curSection;
			if(needShopValue == true){
			for (int i = 0; i < SECTION_NAMES_BENQ.length; i++) {
				curSection = getKeyNamesBenq(SECTION_NAMES_BENQ[i]);
				for (int j = 0; j < curSection.length; j++) {
					iniFile.SetValue(SECTION_NAMES_BENQ[i], curSection[j],
							mStructure.getValue(SECTION_NAMES_BENQ[i], curSection[j]));
				}
			}
			} else {
				for (int i = 0; i < SECTION_NAMES_BENQ.length - 2; i++) {
					curSection = getKeyNamesBenq(SECTION_NAMES_BENQ[i]);
					for (int j = 0; j < curSection.length; j++) {
						iniFile.SetValue(SECTION_NAMES_BENQ[i], curSection[j],
								mStructure.getValue(SECTION_NAMES_BENQ[i], curSection[j]));
					}
				}
			}

			boolean bCloseRet = iniFile.closeINI(mSdcardPath);
			try {
				Runtime.getRuntime().exec("sync");
				Runtime.getRuntime().exec("sync");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				showMessage(getString(R.string.pq_sync_error), getString(R.string.pq_sync_out_error), true);
			}
			if (bCloseRet) {
				return true;// showMessage("", "Export to U disk successfully \n" + mSdcardPath, true);
			} else {
				return false;// showMessage("", "Export to U disk failed！！！ \n", true);
			}

		}
 
	//Save the memory structure directly under the local directory
	private boolean saveToLocal() {
		// TODO Auto-generated method stub
		INIFile iniFile = new INIFile("PQ", mPanelModel);
		// iniFile.openINI(mLocalPath);
		String[] curSection;
		if(needShopValue == true){
			for (int i = 0; i < SECTION_NAMES.length; i++) {
				curSection = getKeyNames(SECTION_NAMES[i]);
				for (int j = 0; j < curSection.length; j++) {
					iniFile.SetValue(SECTION_NAMES[i], curSection[j],
							mStructure.getValue(SECTION_NAMES[i], curSection[j]));

				}
			}
		} else {
			for (int i = 0; i < SECTION_NAMES.length - 2; i++) {
				curSection = getKeyNames(SECTION_NAMES[i]);
				for (int j = 0; j < curSection.length; j++) {
					iniFile.SetValue(SECTION_NAMES[i], curSection[j],
							mStructure.getValue(SECTION_NAMES[i], curSection[j]));

				}
			}
		}
		//If the path does not exist, create the path
		File LocalFile = new File(mLocalPath);
		if (!LocalFile.exists())
		{
			LocalFile.getParentFile().mkdir();
		}	

		if (iniFile.closeINI(mLocalPath)) {
			return true;// showMessage("", "Save successfully!\n" + mLocalPath, true);
		} else {
			return false;// showMessage("", "Save failed!!!", true);
		}
	}
	
	//Save the memory structure directly under the local directory
		private boolean saveToLocalBenq() {
			// TODO Auto-generated method stub
			INIFile iniFile = new INIFile("PQ", mPanelModel);
			// iniFile.openINI(mLocalPath);
			String[] curSection;
			if(needShopValue == true){
			for (int i = 0; i < SECTION_NAMES_BENQ.length; i++) {
				curSection = getKeyNamesBenq(SECTION_NAMES_BENQ[i]);
				for (int j = 0; j < curSection.length; j++) {
					iniFile.SetValue(SECTION_NAMES_BENQ[i], curSection[j],
							mStructure.getValue(SECTION_NAMES_BENQ[i], curSection[j]));

				}
			}
			} else {
				for (int i = 0; i < SECTION_NAMES_BENQ.length - 2; i++) {
					curSection = getKeyNamesBenq(SECTION_NAMES_BENQ[i]);
					for (int j = 0; j < curSection.length; j++) {
						iniFile.SetValue(SECTION_NAMES_BENQ[i], curSection[j],
								mStructure.getValue(SECTION_NAMES_BENQ[i], curSection[j]));

					}
				}
			}
			//If the path does not exist, create the path
			File LocalFile = new File(mLocalPath);
			if (!LocalFile.exists())
			{
				LocalFile.getParentFile().mkdir();
			}	

			if (iniFile.closeINI(mLocalPath)) {
				return true;// showMessage("", "Save successfully!\n" + mLocalPath, true);
			} else {
				return false;// showMessage("", "Save failed!!!", true);
			}
		}

	//From the local directory, read the INI file and save it in the global structure
	private void readIniFile(String local_path) {
		// TODO Auto-generated method stub
		INIFile iniFile = new INIFile("PQ", mPanelModel);
		iniFile.openINI(local_path);
		String[] curSection;
		String curValue;
		for (int i = 0; i < SECTION_NAMES.length; i++) {
			curSection = getKeyNames(SECTION_NAMES[i]);
			for (int j = 0; j < curSection.length; j++) {
				curValue =iniFile.GetValue(SECTION_NAMES[i], curSection[j]);
				if(curValue != null && (!curValue.isEmpty())){
				  mStructure.setValue(SECTION_NAMES[i], curSection[j],curValue);
				}else if((curValue == null && SECTION_NAMES[i].equals("CHTV_PICTUREMODE_SETTING_SHOP"))
						|| curValue == null && SECTION_NAMES[i].equals("CHTV_PICTUREMODE_SETTING")){
					needShopValue = false;
					mStructure.removeSection(SECTION_NAMES[i]);
				}
			}
		}
	}
	
	//From the local directory, read the INI file and save it in the global structure
		private void readIniFileBenq(String local_path) {
			// TODO Auto-generated method stub
			INIFile iniFile = new INIFile("PQ", mPanelModel);
			iniFile.openINI(local_path);
			String[] curSection;
			String curValue;
			Log.d(TAG,"local_path "+local_path);
			for (int i = 0; i < SECTION_NAMES_BENQ.length; i++) {
				curSection = getKeyNamesBenq(SECTION_NAMES_BENQ[i]);
				for (int j = 0; j < curSection.length; j++) {
					curValue =iniFile.GetValue(SECTION_NAMES_BENQ[i], curSection[j]);
					if(curValue != null && (!curValue.isEmpty())){
					  mStructure.setValue(SECTION_NAMES_BENQ[i], curSection[j],curValue);
					} else if((curValue == null && SECTION_NAMES_BENQ[i].equals("CHTV_PICTUREMODE_SETTING_SHOP"))
							|| curValue == null && SECTION_NAMES_BENQ[i].equals("CHTV_PICTUREMODE_SETTING")){
						needShopValue = false;
						mStructure.removeSection(SECTION_NAMES_BENQ[i]);
					}
				}
			}
		}

	//Gets the display position of the interface
	private LayoutParams getWindowManagerParams(WindowPosition wp_position) {
		// TODO Auto-generated method stub
		WindowManager.LayoutParams retParams;
		retParams = new WindowManager.LayoutParams();
		retParams.type = LayoutParams.TYPE_PHONE;
		retParams.format = PixelFormat.RGBA_8888;

		retParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
		retParams.height = WindowManager.LayoutParams.WRAP_CONTENT;

		switch (wp_position) {
		case WP_TOP_LEFT:
			retParams.gravity = Gravity.TOP | Gravity.LEFT;
			retParams.x = BORDER_GAP;
			retParams.y = BORDER_GAP;
			break;
		case WP_TOP_RIGHT:
			retParams.gravity = Gravity.TOP | Gravity.RIGHT;
			retParams.x = BORDER_GAP;
			retParams.y = BORDER_GAP;
			break;
		case WP_BOTTOM_LEFT:
			retParams.gravity = Gravity.BOTTOM | Gravity.LEFT;
			retParams.x = BORDER_GAP;
			retParams.y = BORDER_GAP;
			break;
		case WP_BOTTOM_RIGHT:
			retParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
			retParams.x = BORDER_GAP;
			retParams.y = BORDER_GAP;
			break;
		case WP_CENTER:
			retParams.gravity = Gravity.CENTER;
			retParams.x = 0;
			retParams.y = 0;
			break;
		default:
			break;
		}

		return retParams;
	}

	@Override
	public void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
	}

	//Get the current situational model
	private int getCurrentContextualModeIndex() {
		// TODO Auto-generated method stub
	    //mTvMiscManager.setColorTempture(getENUMColorTempMode(colorModeIndex));
		
		
		int  ColorTempMode = MtkTvConfigTypeBase.VID_CLR_TEMP_USER;
		
		try {
			ColorTempMode=MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_TEMP);//mTvMiscManager.getColorTempture();
//		currentContextualMode = TVManager.getInstance(NewPQService.this)
//				.getMiscManager().getContextualModel();		
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
			showMessage(getString(R.string.pq_error), getString(R.string.pq_get_env_failed), true);
	}
		
//		int contextualModeID = 0;
//		//int currentContextualMode = StaticValues.CHTV_CONTEXTUAL_MODEL_STANDARD;
//		CHENUMPictureMode  currentContextualMode = CHENUMPictureMode.CH_PICTURE_MODE_STANDARD;
//		
//		try {
//			  currentContextualMode=111mTvMiscManager.getPictureMode();
////			currentContextualMode = TVManager.getInstance(NewPQService.this)
////					.getMiscManager().getContextualModel();		
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//			showMessage("error", "获取情景模式失败", true);
//		}
		
//		switch (currentContextualMode) {
//		case StaticValues.CHTV_CONTEXTUAL_MODEL_STANDARD:
//			contextualModeID = 0;
//			break;
//		case StaticValues.CHTV_CONTEXTUAL_MODEL_MOVIE:
//			contextualModeID = 1;
//			break;
//		case StaticValues.CHTV_CONTEXTUAL_MODEL_UMAX:
//			contextualModeID = 2;
//			break;
//		case StaticValues.CHTV_CONTEXTUAL_MODEL_READING:
//			contextualModeID = 3;
//			break;
//		case StaticValues.CHTV_CONTEXTUAL_MODEL_MV:
//			contextualModeID = 4;
//			break;
//		case StaticValues.CHTV_CONTEXTUAL_MODEL_SPORTS:
//			contextualModeID = 5;
//			break;
//		case StaticValues.CHTV_CONTEXTUAL_MODEL_GAME:
//			contextualModeID = 6;
//			break;	
//		case StaticValues.CHTV_CONTEXTUAL_MODEL_USER:
//			contextualModeID = 0;
//			break;					
//		default:
//			contextualModeID = 0;
//			break;
//		}
//		return contextualModeID;
		return ColorTempMode;
	}	
	
	//Set the current scene mode
	private void setTVContextualModel(int tempContextualMode) {
		try{
//			mTvMiscManager.setColorTempture(CHENUMColorTempMode.values()[tempContextualMode]);
			MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_TEMP, tempContextualMode);
			//mTvMiscManager.setPictureMode(CHENUMPictureMode.values()[tempContextualMode]);
//			TVManager.getInstance(NewPQService.this).getMiscManager()
//			.setContextualModel(tempContextualMode);				
		} catch (Exception e){
			showMessage(getString(R.string.pq_error), getString(R.string.pq_set_env_failed), true);
		}		
	}		
	
	//Display GAMMA interface
//	private void showGammaWindow(LinearLayout layout) {
//		mWindowManager.removeView(layout);
//		/*
//		 * if(bVirginGamma) { bVirginGamma = false; if (mLayout_gamma == null) {
//		 * mLayout_gamma = new PQLayout_Gamma(mContext); } } else
//		 * {
//		 */
//		mLayout_gamma = null;
//		mLayout_gamma = new PQLayout_Gamma(mContext);
//		// }
//		mWindowManager.addView(mLayout_gamma,
//				getWindowManagerParams(mWindowPosition));
//	}
//	
    //Display color temperature interface
	private void showColorWindow(LinearLayout layout) {
		mWindowManager.removeView(layout);
		/*
		 * if(bVirginColor) { bVirginColor = false; if (mLayout_color == null) {
		 * mLayout_color = new PQLayout_Color(mContext); } } else
		 * {
		 */
		mLayout_color = null;
		mLayout_color = new PQLayout_Color(mContext);
		// }
		mWindowManager.addView(mLayout_color,
				getWindowManagerParams(mWindowPosition));
	}

	//Show benq five linear interfaces
	private void showBenqWindow(LinearLayout layout) {
		mWindowManager.removeView(layout);
		mLayout_linear_benq = null;
		mLayout_linear_benq = new PQLayout_Linear_Benq(mContext);
		// }
		mWindowManager.addView(mLayout_linear_benq,
				getWindowManagerParams(mWindowPosition));
	}

	//Show five linear interfaces
		private void showLinearWindow(LinearLayout layout) {
			mWindowManager.removeView(layout);
			/*
			 * if(bVirginLinear) { bVirginLinear = false; if (mLayout_linear ==
			 * null) { mLayout_linear = new
			 * PQLayout_Linear(mContext); } } else {
			 */
			mLayout_linear = null;
			mLayout_linear = new PQLayout_Linear(mContext);
			// }
			mWindowManager.addView(mLayout_linear,
					getWindowManagerParams(mWindowPosition));
		}
	//Display main interface
	private void showMainWindow(LinearLayout layout) {
		mWindowManager.removeView(layout);
		if (mLayout_main == null) {
			mLayout_main = new PQLayout_Main(mContext);
			mWindowManager.addView(mLayout_main,
					getWindowManagerParams(mWindowPosition));
		}
		else
		{
			mWindowManager.addView(mLayout_main,
					getWindowManagerParams(mWindowPosition));
			mLayout_main.startScroll();
		}
		
	}

	 //Gets the current color temperature mode   unuse
//	private int getCurrentPQMode() {
//		int picModeID = 0;
//		ENUMPictureMode currentPicMode = ENUMPictureMode.CH_PICTURE_MODE_STANDARD;
//		
//		try {
//			CHENUMPictureMode temp=mTvMiscManager.getPictureMode();
//			currentPicMode = TVManager.getInstance(this).getPictureManager()
//					.getPictureMode();
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (TVManagerNotInitException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		switch (currentPicMode) {
//		case CH_PICTURE_MODE_STANDARD:
//			picModeID = 0;
//			break;
//		case CH_PICTURE_MODE_BRIGHT:
//			picModeID = 1;
//			break;
//		case CH_PICTURE_MODE_SOFT:
//			picModeID = 2;
//			break;
//		case CH_PICTURE_MODE_USER:
//			picModeID = 3;
//			break;
//		default:
//			break;
//		}
//		return picModeID;
//	}

	//According to the current signal source, the corresponding interface display linear grouping source and color temperature grouping source are obtained
	private int getCurrentSignalChannel(boolean isLinear) {

		int SRC_ID = 0;//Linear grouping ID
		int SRC_TEMP_ID = 0;//色温分组ID
//		EnumInputSource currentSource = EnumInputSource.E_INPUT_SOURCE_ATV;

		String currentSource = MtkTvInputSourceBase.INPUT_TYPE_ATV;
		try {
			currentSource = MtkTvInputSource.getInstance().getCurrentInputSourceName();
//			currentSource = mTvCommonManager.getCurrentInputSource();
//			currentSource = TVManager.getInstance(this).getSourceManager()
//					.getCurInputSource(EnumPipInputSource.E_MAIN_INPUT_SOURCE);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			showMessage("error", "Failed to obtain signal channel", true);
		}

		// SRC_TEMP_ID   Originator-ID  
		//SRC_ID   Source packet ID
//		switch (currentSource) {
//		case E_INPUT_SOURCE_ATV: // /<TV input
//			SRC_ID = StaticValues.CHTV_PIC_ATV_PAL;
//			SRC_TEMP_ID = StaticValues.CHTV_SRC_ATV;
//			break;
//		case E_INPUT_SOURCE_DTV: // /<DTV
//			SRC_ID = StaticValues.CHTV_PIC_DTV_SD;
//			SRC_TEMP_ID = StaticValues.CHTV_SRC_DTV;
//			break;
//		case E_INPUT_SOURCE_CVBS: // /<AV 1
//		case E_INPUT_SOURCE_CVBS2: // /<AV 2
//		case E_INPUT_SOURCE_CVBS3: // /<AV 3
//		case E_INPUT_SOURCE_CVBS4: // /<AV 4
//		case E_INPUT_SOURCE_CVBS_MAX:// /<AV max
//
//		case E_INPUT_SOURCE_SVIDEO: // /<S-video 1
//		case E_INPUT_SOURCE_SVIDEO2: // /<S-video 2
//		case E_INPUT_SOURCE_SVIDEO_MAX: // /<S-video max
//		case E_INPUT_SOURCE_SCART: // /<Scart 1
//		case E_INPUT_SOURCE_SCART2: // /<Scart 2
//		case E_INPUT_SOURCE_SCART_MAX: // /<Scart max
//			SRC_ID = StaticValues.CHTV_PIC_AV_PAL;
//			SRC_TEMP_ID = StaticValues.CHTV_SRC_AV;
//			break;
//		case E_INPUT_SOURCE_YPBPR: // /<Component 1
//		case E_INPUT_SOURCE_YPBPR2: // /<Component 2
//		case E_INPUT_SOURCE_YPBPR_MAX: // /<Component max
//			SRC_ID = StaticValues.CHTV_PIC_YPBPR_SD_I;
//			SRC_TEMP_ID = StaticValues.CHTV_SRC_YPBPR;
//			break;
//		case E_INPUT_SOURCE_VGA: // /<VGA input
//			SRC_ID = StaticValues.CHTV_PIC_VGA;
//			SRC_TEMP_ID = StaticValues.CHTV_SRC_VGA;
//			break;
//		case E_INPUT_SOURCE_HDMI: // /<HDMI 1
//		case E_INPUT_SOURCE_HDMI2: // /<HDMI 2
//		case E_INPUT_SOURCE_HDMI3: // /<HDMI 3
//		case E_INPUT_SOURCE_HDMI4: // /HDMI-module
//		case E_INPUT_SOURCE_HDMI_MAX: // /<HDMI max
//			SRC_ID = StaticValues.CHTV_PIC_HDMI_SD_I;
//			SRC_TEMP_ID = StaticValues.CHTV_SRC_HDMI;
//			break;
//		//case E_INPUT_SOURCE_HDMI4: // /HDMI-module
//			//SRC_ID = StaticValues.CHTV_PIC_CHILD_FHD;
//			//SRC_TEMP_ID = StaticValues.CHTV_SRC_HDMI;
//			//break;
//		case E_INPUT_SOURCE_DVI: // /<DVI 1
//		case E_INPUT_SOURCE_DVI2: // /<DVI 2
//		case E_INPUT_SOURCE_DVI3: // /<DVI 2
//		case E_INPUT_SOURCE_DVI4: // /<DVI 4
//		case E_INPUT_SOURCE_DVI_MAX: // /<DVI max
//			SRC_ID = StaticValues.CHTV_PIC_HDMI_SD_I;
//			SRC_TEMP_ID = StaticValues.CHTV_SRC_HDMI;
//			break;
//		case E_INPUT_SOURCE_STORAGE: // /<MEDIAPLAYER
//		case E_INPUT_SOURCE_STORAGE2: // /<MEDIAPLAYER	
//			SRC_ID = StaticValues.CHTV_PIC_MMP_SD;
//			SRC_TEMP_ID = StaticValues.CHTV_SRC_MMP;
//			break;
////			
////		case E_INPUT_SOURCE_NETPLAYER:
////			SRC_ID = StaticValues.CHTV_PIC_NET_SD;
////			SRC_TEMP_ID = StaticValues.CHTV_SRC_NET;
////			break;
////
////		case E_INPUT_SOURCE_IPTV:
////			SRC_ID = StaticValues.CHTV_PIC_UMAX_FHD;
////			SRC_TEMP_ID = StaticValues.CHTV_SRC_NET;
////			break;
//			
//		
//			
//			
//		case E_INPUT_SOURCE_NUM: // /<number of the source
//		case E_INPUT_SOURCE_NONE: // /<NULL input
//			SRC_ID = StaticValues.CHTV_PIC_ATV_PAL;
//			SRC_TEMP_ID = StaticValues.CHTV_SRC_ATV;
//			break;
//		default:
//			SRC_ID = StaticValues.CHTV_PIC_MMP_HD;
//			SRC_TEMP_ID = StaticValues.CHTV_SRC_MMP;
//			break;
//
//		}
//		if(currentSource.equals(MtkTvInputSourceBase.INPUT_TYPE_ATV)){
//			SRC_ID = 0;
//			SRC_TEMP_ID = 0;
//		} else if(currentSource.equals(MtkTvInputSourceBase.INPUT_TYPE_DTV)){
//			SRC_ID = 1;
//			SRC_TEMP_ID = 1;
//		} else if(currentSource.equals(MtkTvInputSourceBase.INPUT_TYPE_DTV)){
//			SRC_ID = 2;
//			SRC_TEMP_ID = 2;
//		} else if(currentSource.equals(MtkTvInputSourceBase.INPUT_TYPE_AV)){
//			SRC_ID = 3;
//			SRC_TEMP_ID = 3;
//		} else if(currentSource.equals(MtkTvInputSourceBase.INPUT_TYPE_COMPONENT)){
//			SRC_ID = 4;
//			SRC_TEMP_ID = 4;
//		} else if(currentSource.equals(MtkTvInputSourceBase.INPUT_TYPE_HDMI)){
//			SRC_ID = 5;
//			SRC_TEMP_ID = 5;
//		} 
		for(int i = 0; i < mUiSourceList.size(); i++){
			if(mUiSourceList.get(i).equalsIgnoreCase(currentSource)){
				SRC_ID = i;
				break;
			}
		}
		if (isLinear) {
			return SRC_ID;//Linear packet source 
		} else {
			return SRC_ID;//SRC_TEMP_ID;//signal source
		}
	}

	//The main interface class contains definitions and operations.
	class PQLayout_Main extends LinearLayout {

		Button bt_linear, bt_color, bt_lightsensor_linear_benq,bt_panelType, bt_stepSize,
				bt_position,bt_resetWB, bt_save, bt_exit;
		EditText et_versionNumber, et_panelModel;

		public PQLayout_Main(Context context) {
			super(context);
			// TODO Auto-generated constructor stub
			mInflater.inflate(R.layout.pq_main, this);

			bt_linear = (Button) findViewById(R.id.bt_linear);
			bt_linear.setNextFocusLeftId(R.id.bt_linear);
			bt_linear.setNextFocusRightId(R.id.bt_linear);
			bt_linear.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					// TODO Auto-generated method stub
					showLinearWindow(mLayout_main);
				}
			});
//			bt_linear.setOnKeyListener(new OnKeyListener() {
//
//				@Override
//				public boolean onKey(View v, int keyCode, KeyEvent event) {
//					// TODO Auto-generated method stub
//					if (event.getAction() == KeyEvent.ACTION_UP) {
//						switch (keyCode) {
//						case KeyEvent.KEYCODE_DPAD_CENTER:
//						case KeyEvent.KEYCODE_DPAD_LEFT:
//						case KeyEvent.KEYCODE_DPAD_RIGHT:
//							if (timer != null) {
//								timer.cancel();
//							}
//							Log.v("newpqactivity", "bt_linear onEnterRightKey");
//							showLinearWindow(mLayout_main);
//							return true;
//						default:
//							return false;
//						}
//					}
//					return false;
//				}
//			});

			bt_color = (Button) findViewById(R.id.bt_color);
			bt_color.setNextFocusLeftId(bt_color.getId());
			bt_color.setNextFocusRightId(bt_color.getId());
			bt_color.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_UP) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_CENTER:
						case KeyEvent.KEYCODE_DPAD_LEFT:
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if (timer != null) {
								timer.cancel();
							}
							showColorWindow(mLayout_main);
							return true;
						default:
							return false;
						}
					}
					return false;
				}
			});

			
			bt_lightsensor_linear_benq = (Button) findViewById(R.id.bt_lightsensor_linear_benq);
			bt_lightsensor_linear_benq.setNextFocusRightId(bt_lightsensor_linear_benq.getId());
			bt_lightsensor_linear_benq.setNextFocusLeftId(bt_lightsensor_linear_benq.getId());
			bt_lightsensor_linear_benq.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_UP) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_CENTER:
						case KeyEvent.KEYCODE_DPAD_LEFT:
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if (timer != null) {
								timer.cancel();
							}
//							showGammaWindow(mLayout_main);
							showBenqWindow(mLayout_main);
							return true;
						default:
							return false;
						}
					}
					return false;
				}
			});
//            if(SystemProperties.get("ro.product.brand", "CHANGHONG").equalsIgnoreCase("BenQ")){
//            	bt_lightsensor_linear_benq.setVisibility(View.VISIBLE);
//            };
//			
			et_versionNumber = (EditText) findViewById(R.id.et_versionNumber);
			et_versionNumber.setNextFocusLeftId(et_versionNumber.getId());
			et_versionNumber.setNextFocusRightId(et_versionNumber.getId());
			mVersionNumber = MtkTvFApiInformation.getInstance().getSwVersion();//mStructure.getValue("IniVersion", "Ver");
			et_versionNumber.setText(mVersionNumber);
			et_versionNumber
					.setOnFocusChangeListener(new OnFocusChangeListener() {

						@Override
						public void onFocusChange(View v, boolean hasFocus) {
							// TODO Auto-generated method stub
							if (hasFocus) {
								if (timer != null) {
									timer.cancel();
								}
								et_versionNumber.setText(mVersionNumber);
							} else {

								mVersionNumber = et_versionNumber.getText()
										.toString().trim();
								mStructure.setValue("IniVersion", "Ver",
										mVersionNumber);
								if (mVersionNumber.length() > MAX_STRING_LENGTH) {
									startScroll();
								}
							}

						}
					});

			et_panelModel = (EditText) findViewById(R.id.et_panelModel);
			et_panelModel.setNextFocusLeftId(et_panelModel.getId());
			et_panelModel.setNextFocusRightId(et_panelModel.getId());
			mPanelModel = getPanelModel();
			et_panelModel.setText(mPanelModel);
			/*
			 * et_panelModel.setOnFocusChangeListener(new
			 * OnFocusChangeListener() {
			 * 
			 * @Override public void onFocusChange(View v, boolean hasFocus) {
			 * // TODO Auto-generated method stub if (hasFocus) {
			 * 
			 * } else { mPanelModel = et_panelModel.getText().toString().trim();
			 * updateFileNameAndPath(mPanelModel); }
			 * 
			 * } });
			 */

			bt_panelType = (Button) findViewById(R.id.bt_panelType);
			bt_panelType.setNextFocusRightId(bt_panelType.getId());
			bt_panelType.setNextFocusLeftId(bt_panelType.getId());
			////less of MTK
//			mPanelType = getCurrentPanelType();
//			switch (mPanelType) {
//			case PANEL_LCD:
//				bt_panelType.setText(getString(R.string.pq_screen_type_LCD));
//				break;
//			case PANEL_PDP:
//				bt_panelType.setText(getString(R.string.pq_screen_type_PDP));
//				break;
//			default:
//				//OLED
//				mPanelType = EnumPanelType.PANEL_LCD;
//				bt_panelType.setText(getString(R.string.pq_screen_type_LCD));
//				break;
//			}
			bt_panelType.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_UP) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_CENTER:
							break;
						case KeyEvent.KEYCODE_DPAD_LEFT:
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							//less of MTK
//							switch (mPanelType) {
//							case PANEL_PDP:
//								mPanelType = EnumPanelType.PANEL_LCD;
//								bt_panelType.setText("◀ LCD screen ▶");
//								break;
//							case PANEL_LCD:
//								mPanelType = EnumPanelType.PANEL_PDP;
//								bt_panelType.setText("◀ Plasma screen ▶");
//								break;
//							}

							return true;
						default:
							return false;
						}
					}
					return false;
				}
			});

			bt_stepSize = (Button) findViewById(R.id.bt_stepSize);
			bt_stepSize.setNextFocusRightId(bt_stepSize.getId());
			bt_stepSize.setNextFocusLeftId(bt_stepSize.getId());
			bt_stepSize.setText("◀ " + mStepSize + " ▶");
			bt_stepSize.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					Log.v("tvtool", "keycode:" + keyCode);
					Log.v("tvtool", "event:" + event.toString());
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_CENTER:
							if ((mStepSize % 10) == 0) {
								mStepSize = (mStepSize + 10) % 110;
								if (mStepSize == 0) {
									mStepSize = 1;
								}
							} else {
								mStepSize = 10;
							}
							break;
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if (mStepSize > 1) {
								mStepSize--;
							}
							break;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if (mStepSize < 100) {
								mStepSize++;
							}
							break;
						default:
							return false;
						}
						bt_stepSize.setText("◀ " + mStepSize + " ▶");
					}
						 
					return false;
				}
			});
			bt_stepSize.setOnLongClickListener(new OnLongClickListener() {
				
				@Override
				public boolean onLongClick(View arg0) {
					// TODO Auto-generated method stub
					return false;
				}
			});

			bt_position = (Button) findViewById(R.id.bt_position);
			bt_position.setNextFocusLeftId(R.id.bt_position);
			bt_position.setNextFocusRightId(bt_position.getId());
			bt_position.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_UP) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							mWindowPosition = WindowPosition
									.getPrev(mWindowPosition);
							refreshWindowPosition(mLayout_main, mWindowPosition);
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							mWindowPosition = WindowPosition
									.getNext(mWindowPosition);
							refreshWindowPosition(mLayout_main, mWindowPosition);
							return true;
						case KeyEvent.KEYCODE_DPAD_CENTER:
							
//							SimpleINIEditor editor = new SimpleINIEditor(mContext);
//							editor.loadFile(mLocalPath);
//							editor.addComment(";this is a new ini editor");
//							boolean b = editor.saveFile(mLocalPath);
//							if(b)
//							{
//								Toast.makeText(mContext, "done", Toast.LENGTH_LONG).show();
//							}
//							else
//							{
//								Toast.makeText(mContext, " write error ", Toast.LENGTH_LONG).show();
//							}
							
							break;
						}
					}

					return false;
				}
			});
			
			//Reset white balance
			bt_resetWB = (Button) findViewById(R.id.bt_resetWB);
			bt_resetWB.setNextFocusLeftId(R.id.bt_resetWB);
			bt_resetWB.setNextFocusRightId(bt_resetWB.getId());
			bt_resetWB.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_UP) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_RIGHT:
						case KeyEvent.KEYCODE_DPAD_CENTER:	 
							try {
									Log.v(TAG,"ResetColorTempEepromStatus");
									//less of MTK
//									mTvMiscManager.setTvToolColorTempEeprom ();	
									//TVManager.getInstance(NewPQService.this).getSystemManager().ResetColorTempEepromStatus();									
									Toast.makeText(mContext, getString(R.string.reset_white_balance_success), Toast.LENGTH_LONG).show();																	
							    } catch (Exception e) {
								   Toast.makeText(mContext, getString(R.string.reset_white_balance_success), Toast.LENGTH_LONG).show();
								   e.printStackTrace();
							    }
							
							return true;
						
						}
					}

					return false;
				}
			});
			
			
			
			
			

			bt_save = (Button) findViewById(R.id.bt_save);
			bt_save.setText(getString(R.string.save_exit));
			bt_save.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
//					if(SystemProperties.get("ro.product.brand", "CHANGHONG").equalsIgnoreCase("BenQ")){
//						saveAndExportBenq();
//					} else {
					    saveAndExport();
//					}
				}
			});

			bt_exit = (Button) findViewById(R.id.bt_exit);
			bt_exit.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					// TODO Auto-generated method stub
					/*
					 * if (timer != null) { timer.cancel(); } exitPQ();
					 */
					KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN,
							KeyEvent.KEYCODE_BACK);
					dispatchKeyEvent(event);
				}
			});
			handler = new Handler() {

				@Override
				public void handleMessage(Message msg) {
					// TODO Auto-generated method stub
					super.handleMessage(msg);

					if (scrollIndex >= mVersionNumber.length()) {
						scrollIndex = 0;
					}
					mScrollString1 = mVersionNumber.substring(scrollIndex);
					mScrollString2 = "    " + mVersionNumber;
					scrollIndex++;
					et_versionNumber.setText(mScrollString1 + mScrollString2);

				}

			};

			if (mVersionNumber.length() > MAX_STRING_LENGTH) {
				startScroll();
			}

		}

		public void startScroll() {
			// TODO Auto-generated method stub
			if (mVersionNumber.length() <= MAX_STRING_LENGTH) {
				return;
			}
			timer = new Timer();
			timerTask = new TimerTask() {

				@Override
				public void run() {
					// TODO Auto-generated method stub
					handler.sendEmptyMessage(0);
				}

			};
			timer.schedule(timerTask, 0, 500);
		}

		//获取当前屏的类型 PDP OR LCD
		//less of MTK
//		private EnumPanelType getCurrentPanelType() {
//			// TODO Auto-generated method stub
//			EnumPanelType currentPanelType = EnumPanelType.PANEL_LCD;
//
//			try {
//				
//				PanelInfo currentPanelInfo =mTvMiscManager.getPanelInfo(null);
////				PanelInfo currentPanelInfo = TVManager
////						.getInstance(NewPQService.this).getMiscManager()
////						.getPanelInfo();
//				currentPanelType = currentPanelInfo.mePanelType;
//			} catch (Exception e) {
//				// TODO Auto-generated catch block
//				e.printStackTrace();
//				Toast.makeText(NewPQService.this, "getCurrentPanelType:Get screen type exception", Toast.LENGTH_LONG).show();
//			}
//			return currentPanelType;
//		}

		PQLayout_Message layout_message;
		
		//Heavy load interface button operation
		@Override
		public boolean dispatchKeyEvent(KeyEvent event) {
			// TODO Auto-generated method stub
			if (event.getAction() == KeyEvent.ACTION_DOWN
					&& event.getKeyCode() == KeyEvent.KEYCODE_BACK) {

				View.OnClickListener listener = new OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						if (timer != null) {
							timer.cancel();
						}
						layout_message.hide();
						exitPQ();
					}
				};
				layout_message = new PQLayout_Message(mContext,
						false).setMessage("", getString(R.string.pq_sure_exit)).setOKListener(listener);
				layout_message.show();
				return true;
			}
			return super.dispatchKeyEvent(event);
		}

		//Refresh the window position adjustment in the main interface
		protected void refreshWindowPosition(LinearLayout layout,
				WindowPosition curWindowPosition) {
			// TODO Auto-generated method stub
			mWindowManager.removeView(layout);
			bt_position.setText(WINDOW_POSITION_NAMES[curWindowPosition
					.ordinal()]);
			mWindowManager.addView(layout,
					getWindowManagerParams(curWindowPosition));
		}

	    //Change the main interface screen parameter display
		public void set_et_panelModel_text(String text) {
			et_panelModel.setText(text);
		}

	}

	//Linear display interface class, definition, operation
	class PQLayout_Linear extends LinearLayout {

//		FlowRadioGroup  rg_adjustItem;
		Button rg_signalChannels, rg_adjustItem;
		LinearLayout ll_brightness, ll_contrast, ll_saturation, ll_sharpness,
				ll_hue;

		Button bt_curAnologQuantity, bt_v0, bt_v25, bt_v50, bt_v75, bt_v100;
		TextView tv_v0, tv_v25, tv_v50, tv_v75, tv_v100;
		int curSignalChannelIndex = 0;
		int curPQMode = 0;
		int curAdjustItem = 0;
		int[] curAnologQuantitys = { 0, 0, 0, 0, 0 };// Each adjustment option corresponds to one
		int[][] curLinearValues = { {0, 0, 0, 0, 0},{0, 0, 0, 0, 0},{0, 0, 0, 0, 0},{0, 0, 0, 0, 0},{0, 0, 0, 0, 0} };// The value of the v0~v100 corresponding to the current tuning option
		boolean bSpinnerPQModeHasFocus = false;
		boolean bCenterPressed = false;

		Button bt_save, bt_exit;

		public PQLayout_Linear(Context context) {
			super(context);
			// TODO Auto-generated constructor stub
			mInflater.inflate(R.layout.pq_linear, this);

			rg_signalChannels = (Button) findViewById(R.id.rg_signalChannels_linear);
			curSignalChannelIndex = getCurrentSignalChannel(true);
			rg_signalChannels.setText(SourceName[curSignalChannelIndex]+"▶");

			rg_signalChannels.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_UP) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_RIGHT:
						case KeyEvent.KEYCODE_DPAD_CENTER:	 
							try {
								showAlertDialog("source");

							    } catch (Exception e) {
								   
							    }
							
							return true;
						
						}
					}

					return false;
				}
			});



			curPQMode = MtkTvConfigTypeBase.VID_CLR_TEMP_STANDARD;//CHENUMColorTempMode.CH_COLOR_TEMP_STANDARD.ordinal();//getCurrentContextualModeIndex();									



			//Five dimensional linear drop-down bar entry
			rg_adjustItem = (Button) findViewById(R.id.rg_adjustItem);
			String[] list1=getResources().getStringArray(R.array.pq_adjust_item);
			rg_adjustItem.setText(list1[curAdjustItem]+"▶");
			rg_adjustItem.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_UP) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_RIGHT:
						case KeyEvent.KEYCODE_DPAD_CENTER:	 
							try {
								showAlertDialog("operation");

							    } catch (Exception e) {
								   
							    }
							
							return true;
						
						}
					}

					return false;
				}
			});
			
			

			bt_curAnologQuantity = (Button) findViewById(R.id.bt_curAnologQuantity);
			bt_curAnologQuantity.setNextFocusLeftId(bt_curAnologQuantity
					.getId());
			bt_curAnologQuantity.setNextFocusRightId(bt_curAnologQuantity
					.getId());
			initCurAnologQuantity();
			bt_curAnologQuantity
					.setText(getFormatString(curAnologQuantitys[curAdjustItem]));
			bt_curAnologQuantity.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							bCenterPressed = false;
							//if (curPQMode != StaticValues.CHTV_CONTEXTUAL_MODEL_USER) {
								curAnologQuantitys[curAdjustItem] = getCurAnologQuantity(
										curPQMode, curAdjustItem);
								bSpinnerPQModeHasFocus = false;
//								sp_pqMode.setSelection(0, true);
						//	}

							if (curAdjustItem == 4) {

								if (curAnologQuantitys[curAdjustItem] == -50) {
									curAnologQuantitys[curAdjustItem] = 50;
								} else if (curAnologQuantitys[curAdjustItem] > -50) {
									curAnologQuantitys[curAdjustItem] -= mStepSize;
									if (curAnologQuantitys[curAdjustItem] < -50) {
										curAnologQuantitys[curAdjustItem] = -50;
									}
								}
							} else if(curAdjustItem == 3){
								if (curAnologQuantitys[curAdjustItem] == 0) {
									curAnologQuantitys[curAdjustItem] = 0;
								} else if (curAnologQuantitys[curAdjustItem] > 0) {
									curAnologQuantitys[curAdjustItem] -= mStepSize;
									if (curAnologQuantitys[curAdjustItem] > 20) {
										curAnologQuantitys[curAdjustItem] = 20;
									}
								}
							}else {
								if (curAnologQuantitys[curAdjustItem] == 0) {
									curAnologQuantitys[curAdjustItem] = 100;
								} else if (curAnologQuantitys[curAdjustItem] > 0) {
									curAnologQuantitys[curAdjustItem] -= mStepSize;
									if (curAnologQuantitys[curAdjustItem] < 0) {
										curAnologQuantitys[curAdjustItem] = 0;
									}
								}
							}
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
							refreshCurAnologQuantity(curPQMode, curAdjustItem);
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							bCenterPressed = false;
						//	if (curPQMode != StaticValues.CHTV_CONTEXTUAL_MODEL_USER) {
								curAnologQuantitys[curAdjustItem] = getCurAnologQuantity(
										curPQMode, curAdjustItem);
								bSpinnerPQModeHasFocus = false;
//								sp_pqMode.setSelection(0, true);
						//	}

							if (curAdjustItem == 4) {

								if (curAnologQuantitys[curAdjustItem] == 50) {
									curAnologQuantitys[curAdjustItem] = -50;
								} else if (curAnologQuantitys[curAdjustItem] < 50) {
									curAnologQuantitys[curAdjustItem] += mStepSize;
									if (curAnologQuantitys[curAdjustItem] > 50) {
										curAnologQuantitys[curAdjustItem] = 50;
									}
								}
							} else if(curAdjustItem == 3){
								if (curAnologQuantitys[curAdjustItem] >= 20) {
									curAnologQuantitys[curAdjustItem] = 20;
								} else if (curAnologQuantitys[curAdjustItem] < 20) {
									curAnologQuantitys[curAdjustItem] += mStepSize;

								}
							}else {
								
								if(curAnologQuantitys[curAdjustItem] == 100)
								{
									curAnologQuantitys[curAdjustItem] = 0;
								}
								else if (curAnologQuantitys[curAdjustItem] < 100) {
									curAnologQuantitys[curAdjustItem] += mStepSize;
									if (curAnologQuantitys[curAdjustItem] > 100) {
										curAnologQuantitys[curAdjustItem] = 100;
									}
								}
							}
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
							refreshCurAnologQuantity(curPQMode, curAdjustItem);
							return true;
						case KeyEvent.KEYCODE_DPAD_CENTER:
					//		if (curPQMode != StaticValues.CHTV_CONTEXTUAL_MODEL_USER) {
								curAnologQuantitys[curAdjustItem] = getCurAnologQuantity(
										curPQMode, curAdjustItem);
								bSpinnerPQModeHasFocus = false;
//								sp_pqMode.setSelection(0, true);
					//		}
							if (bCenterPressed == false) {
								bCenterPressed = true;
								if (curAdjustItem == 4) {
									curAnologQuantitys[curAdjustItem] = -50;
								}else if(curAdjustItem == 3) {
									curAnologQuantitys[curAdjustItem] = 10;
								} else {
									curAnologQuantitys[curAdjustItem] = 0;
								}
							} else {
								if (curAdjustItem == 4) {
									curAnologQuantitys[curAdjustItem] += 10;
									if (curAnologQuantitys[curAdjustItem] > 50) {
										curAnologQuantitys[curAdjustItem] = -50;
									}
								}else if(curAdjustItem == 3) {
									curAnologQuantitys[curAdjustItem] += 10;
									if (curAnologQuantitys[curAdjustItem] > 20) {
										curAnologQuantitys[curAdjustItem] = 0;
									}
								} else {
									curAnologQuantitys[curAdjustItem] += 10;
									if (curAnologQuantitys[curAdjustItem] > 100) {
										curAnologQuantitys[curAdjustItem] = 0;
									}
								}
							}
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
							refreshCurAnologQuantity(curPQMode, curAdjustItem);

							return true;
						default:
							break;
						}

					}
					return false;
				}
			});

			bt_v0 = (Button) findViewById(R.id.bt_v0);
			tv_v0 = (TextView) findViewById(R.id.tv_v0);
			bt_v0.setNextFocusLeftId(bt_v0.getId());
			bt_v0.setNextFocusRightId(bt_v0.getId());
			bt_v0.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if(curLinearValues[curAdjustItem][0] == 0)
							{
								curLinearValues[curAdjustItem][0] = maxValue[0];
							}
							else
							{
								curLinearValues[curAdjustItem][0] -= 1;
								if (curLinearValues[curAdjustItem][0] < 0) {
									curLinearValues[curAdjustItem][0] = 0;
								}
							}
//							curLinearValues[1] = (curLinearValues[0] + curLinearValues[2]) / 2;
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v0.setText(getFormatString(curLinearValues[curAdjustItem][0]));
							tv_v0.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][0])
									+ ")");
//							bt_v25.setText(getFormatString(curLinearValues[1]));
//							tv_v25.setText("(0x"
//									+ Integer.toHexString(curLinearValues[1])
//									+ ")");
							setTVLinearValues(curAdjustItem, 0,
									curLinearValues[curAdjustItem][0]);
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
//							setTVLinearValues(curAdjustItem, 1,
//									curLinearValues[1]);
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							
							if(curLinearValues[curAdjustItem][0] == maxValue[0])
							{
								curLinearValues[curAdjustItem][0] = 0;
							}
							else
							{
								curLinearValues[curAdjustItem][0] += 1;
								if (curLinearValues[curAdjustItem][0] > maxValue[0]) {
									curLinearValues[curAdjustItem][0] = maxValue[0];
								}								
							}
//							curLinearValues[1] = (curLinearValues[0] + curLinearValues[2]) / 2;
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v0.setText(getFormatString(curLinearValues[curAdjustItem][0]));
							tv_v0.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][0])
									+ ")");
//							bt_v25.setText(getFormatString(curLinearValues[1]));
//							tv_v25.setText("(0x"
//									+ Integer.toHexString(curLinearValues[1])
//									+ ")");
							setTVLinearValues(curAdjustItem, 0,
									curLinearValues[curAdjustItem][0]);
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
//							setTVLinearValues(curAdjustItem, 1,
//									curLinearValues[1]);
							return true;
						case KeyEvent.KEYCODE_DPAD_CENTER:
							if(curLinearValues[curAdjustItem][0] == maxValue[0])
							{
								curLinearValues[curAdjustItem][0] = 0;
							}
							else 
							{
								curLinearValues[curAdjustItem][0] += 10;
								if (curLinearValues[curAdjustItem][0] > maxValue[0]) {
									curLinearValues[curAdjustItem][0] = maxValue[0];
								}
							}
//							curLinearValues[1] = (curLinearValues[0] + curLinearValues[2]) / 2;
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v0.setText(getFormatString(curLinearValues[curAdjustItem][0]));
							tv_v0.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][0])
									+ ")");
//							bt_v25.setText(getFormatString(curLinearValues[1]));
//							tv_v25.setText("(0x"
//									+ Integer.toHexString(curLinearValues[1])
//									+ ")");
							setTVLinearValues(curAdjustItem, 0,
									curLinearValues[curAdjustItem][0]);
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
//							setTVLinearValues(curAdjustItem, 1,
//									curLinearValues[1]);							
							break;
						}
					}
					return false;
				}
			});

			bt_v25 = (Button) findViewById(R.id.bt_v25);
			tv_v25 = (TextView) findViewById(R.id.tv_v25);
			bt_v25.setNextFocusLeftId(bt_v25.getId());
			bt_v25.setNextFocusRightId(bt_v25.getId());
			bt_v25.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if(curLinearValues[curAdjustItem][1] == 0)
							{
								curLinearValues[curAdjustItem][1] = maxValue[1];
							}
							else
							{
								curLinearValues[curAdjustItem][1] -= 1;
								if (curLinearValues[curAdjustItem][1] < 0) {
									curLinearValues[curAdjustItem][1] = 0;
								}
							}
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v25.setText(getFormatString(curLinearValues[curAdjustItem][1]));
							tv_v25.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][1])
									+ ")");
							setTVLinearValues(curAdjustItem, 1,
									curLinearValues[curAdjustItem][1]);
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if(curLinearValues[curAdjustItem][1] == maxValue[1])
							{
								curLinearValues[curAdjustItem][1] = 0;
							}
							else
							{
								curLinearValues[curAdjustItem][1] += 1;
								if (curLinearValues[curAdjustItem][1] > maxValue[1]) {
									curLinearValues[curAdjustItem][1] = maxValue[1];
								}
							}
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v25.setText(getFormatString(curLinearValues[curAdjustItem][1]));
							tv_v25.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][1])
									+ ")");
							setTVLinearValues(curAdjustItem, 1,
									curLinearValues[curAdjustItem][1]);
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
							return true;
						case KeyEvent.KEYCODE_DPAD_CENTER:
							if(curLinearValues[curAdjustItem][1] == maxValue[1])
							{
								curLinearValues[curAdjustItem][1] = 0;
							}
							else 
							{
								curLinearValues[curAdjustItem][1] += 10;
								if (curLinearValues[curAdjustItem][1] > maxValue[1]) {
									curLinearValues[curAdjustItem][1] = maxValue[1];
								}
							}
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v25.setText(getFormatString(curLinearValues[curAdjustItem][1]));
							tv_v25.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][1])
									+ ")");
							setTVLinearValues(curAdjustItem, 1,
									curLinearValues[curAdjustItem][1]);	
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
							break;
						}
					}
					return false;
				}
			});

			bt_v50 = (Button) findViewById(R.id.bt_v50);
			tv_v50 = (TextView) findViewById(R.id.tv_v50);
			bt_v50.setNextFocusLeftId(bt_v50.getId());
			bt_v50.setNextFocusRightId(bt_v50.getId());
			bt_v50.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if(curLinearValues[curAdjustItem][2] == 0)
							{
								curLinearValues[curAdjustItem][2] = maxValue[2];
							}
							else
							{
								curLinearValues[curAdjustItem][2] -= 1;
								if (curLinearValues[curAdjustItem][2] < 0) {
									curLinearValues[curAdjustItem][2] = 0;
								}
							}
//							curLinearValues[1] = (curLinearValues[0] + curLinearValues[2]) / 2;
//							curLinearValues[3] = (curLinearValues[2] + curLinearValues[4]) / 2;
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v50.setText(getFormatString(curLinearValues[curAdjustItem][2]));
							tv_v50.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][2])
									+ ")");
//							bt_v25.setText(getFormatString(curLinearValues[1]));
//							tv_v25.setText("(0x"
//									+ Integer.toHexString(curLinearValues[1])
//									+ ")");
//							bt_v75.setText(getFormatString(curLinearValues[3]));
//							tv_v75.setText("(0x"
//									+ Integer.toHexString(curLinearValues[3])
//									+ ")");
							setTVLinearValues(curAdjustItem, 2,
									curLinearValues[curAdjustItem][2]);
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
//							setTVLinearValues(curAdjustItem, 1,
//									curLinearValues[1]);
//							setTVLinearValues(curAdjustItem, 3,
//									curLinearValues[3]);
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if(curLinearValues[curAdjustItem][2] == maxValue[2])
							{
								curLinearValues[curAdjustItem][2] = 0;
							}
							else
							{
								curLinearValues[curAdjustItem][2] += 1;
								if (curLinearValues[curAdjustItem][2] > maxValue[2]) {
									curLinearValues[curAdjustItem][2] = maxValue[2];
								}
							}
//							curLinearValues[1] = (curLinearValues[0] + curLinearValues[2]) / 2;
//							curLinearValues[3] = (curLinearValues[2] + curLinearValues[4]) / 2;
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v50.setText(getFormatString(curLinearValues[curAdjustItem][2]));
							tv_v50.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][2])
									+ ")");
//							bt_v25.setText(getFormatString(curLinearValues[1]));
//							tv_v25.setText("(0x"
//									+ Integer.toHexString(curLinearValues[1])
//									+ ")");
//							bt_v75.setText(getFormatString(curLinearValues[3]));
//							tv_v75.setText("(0x"
//									+ Integer.toHexString(curLinearValues[3])
//									+ ")");
							setTVLinearValues(curAdjustItem, 2,
									curLinearValues[curAdjustItem][2]);
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
//							setTVLinearValues(curAdjustItem, 1,
//									curLinearValues[1]);
//							setTVLinearValues(curAdjustItem, 3,
//									curLinearValues[3]);
							return true;
						case KeyEvent.KEYCODE_DPAD_CENTER:
							if(curLinearValues[curAdjustItem][2] == maxValue[2])
							{
								curLinearValues[curAdjustItem][2] = 0;
							}
							else
							{
								curLinearValues[curAdjustItem][2] += 10;
								if (curLinearValues[curAdjustItem][2] > maxValue[2]) {
									curLinearValues[curAdjustItem][2] = maxValue[2];
								}
							}
//							curLinearValues[1] = (curLinearValues[0] + curLinearValues[2]) / 2;
//							curLinearValues[3] = (curLinearValues[2] + curLinearValues[4]) / 2;
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v50.setText(getFormatString(curLinearValues[curAdjustItem][2]));
							tv_v50.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][2])
									+ ")");
//							bt_v25.setText(getFormatString(curLinearValues[1]));
//							tv_v25.setText("(0x"
//									+ Integer.toHexString(curLinearValues[1])
//									+ ")");
//							bt_v75.setText(getFormatString(curLinearValues[3]));
//							tv_v75.setText("(0x"
//									+ Integer.toHexString(curLinearValues[3])
//									+ ")");
							setTVLinearValues(curAdjustItem, 2,
									curLinearValues[curAdjustItem][2]);
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
//							setTVLinearValues(curAdjustItem, 1,
//									curLinearValues[1]);
//							setTVLinearValues(curAdjustItem, 3,
//									curLinearValues[3]);
							break;
						}
					}
					return false;
				}
			});

			bt_v75 = (Button) findViewById(R.id.bt_v75);
			tv_v75 = (TextView) findViewById(R.id.tv_v75);
			bt_v75.setNextFocusLeftId(bt_v75.getId());
			bt_v75.setNextFocusRightId(bt_v75.getId());
			bt_v75.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if(curLinearValues[curAdjustItem][3] == 0)
							{
								curLinearValues[curAdjustItem][3] = maxValue[3];
							}
							else
							{
								curLinearValues[curAdjustItem][3] -= 1;
								if (curLinearValues[curAdjustItem][3] < 0) {
									curLinearValues[curAdjustItem][3] = 0;
								}
							}
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v75.setText(getFormatString(curLinearValues[curAdjustItem][3]));
							tv_v75.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][3])
									+ ")");
							setTVLinearValues(curAdjustItem, 3,
									curLinearValues[curAdjustItem][3]);
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if(curLinearValues[curAdjustItem][3] == maxValue[3])
							{
								curLinearValues[curAdjustItem][3] = 0;
							}
							else
							{
								curLinearValues[curAdjustItem][3] += 1;
								if (curLinearValues[curAdjustItem][3] > maxValue[3]) {
									curLinearValues[curAdjustItem][3] = maxValue[3];
								}								
							}
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v75.setText(getFormatString(curLinearValues[curAdjustItem][3]));
							tv_v75.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][3])
									+ ")");
							setTVLinearValues(curAdjustItem, 3,
									curLinearValues[curAdjustItem][3]);
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
							return true;
						case KeyEvent.KEYCODE_DPAD_CENTER:
							if(curLinearValues[curAdjustItem][3] == maxValue[3])
							{
								curLinearValues[curAdjustItem][3] = 0;
							}
							else
							{
								curLinearValues[curAdjustItem][3] += 10;
								if (curLinearValues[curAdjustItem][3] > maxValue[3]) {
									curLinearValues[curAdjustItem][3] = maxValue[3];
								}								
							}
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v75.setText(getFormatString(curLinearValues[curAdjustItem][3]));
							tv_v75.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][3])
									+ ")");
							setTVLinearValues(curAdjustItem, 3,
									curLinearValues[curAdjustItem][3]);
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
							return true;
						}
					}
					return false;
				}
			});

			bt_v100 = (Button) findViewById(R.id.bt_v100);
			tv_v100 = (TextView) findViewById(R.id.tv_v100);
			bt_v100.setNextFocusLeftId(bt_v100.getId());
			bt_v100.setNextFocusRightId(bt_v100.getId());
			bt_v100.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if(curLinearValues[curAdjustItem][4] == 0)
							{
								curLinearValues[curAdjustItem][4] = maxValue[4];
							}
							else
							{
								curLinearValues[curAdjustItem][4] -= 1;
								if (curLinearValues[curAdjustItem][4] < 0) {
									curLinearValues[curAdjustItem][4] = 0;
								}
							}
//							curLinearValues[3] = (curLinearValues[2] + curLinearValues[4]) / 2;
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v100.setText(getFormatString(curLinearValues[curAdjustItem][4]));
							tv_v100.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][4])
									+ ")");
//							bt_v75.setText(getFormatString(curLinearValues[3]));
//							tv_v75.setText("(0x"
//									+ Integer.toHexString(curLinearValues[3])
//									+ ")");
							setTVLinearValues(curAdjustItem, 4,
									curLinearValues[curAdjustItem][4]);
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
//							setTVLinearValues(curAdjustItem, 3,
//									curLinearValues[3]);
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if(curLinearValues[curAdjustItem][4] == maxValue[4])
							{
								curLinearValues[curAdjustItem][4] = 0;
							}
							else
							{
								curLinearValues[curAdjustItem][4] += 1;
								if (curLinearValues[curAdjustItem][4] > maxValue[4]) {
									curLinearValues[curAdjustItem][4] = maxValue[4];
								}
							}
//							curLinearValues[3] = (curLinearValues[2] + curLinearValues[4]) / 2;
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v100.setText(getFormatString(curLinearValues[curAdjustItem][4]));
							tv_v100.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][4])
									+ ")");
//							bt_v75.setText(getFormatString(curLinearValues[3]));
//							tv_v75.setText("(0x"
//									+ Integer.toHexString(curLinearValues[3])
//									+ ")");
							setTVLinearValues(curAdjustItem, 4,
									curLinearValues[curAdjustItem][4]);
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
//							setTVLinearValues(curAdjustItem, 3,
//									curLinearValues[3]);
							return true;
						case KeyEvent.KEYCODE_DPAD_CENTER:
							if(curLinearValues[curAdjustItem][4] == maxValue[4])
							{
								curLinearValues[curAdjustItem][4] = 0;
							}
							else
							{
								curLinearValues[curAdjustItem][4] += 10;
								if (curLinearValues[curAdjustItem][4] > maxValue[4]) {
									curLinearValues[curAdjustItem][4] = maxValue[4];
								}
							}
//							curLinearValues[3] = (curLinearValues[2] + curLinearValues[4]) / 2;
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
							bt_v100.setText(getFormatString(curLinearValues[curAdjustItem][4]));
							tv_v100.setText("(0x"
									+ Integer.toHexString(curLinearValues[curAdjustItem][4])
									+ ")");
//							bt_v75.setText(getFormatString(curLinearValues[3]));
//							tv_v75.setText("(0x"
//									+ Integer.toHexString(curLinearValues[3])
//									+ ")");
							setTVLinearValues(curAdjustItem, 4,
									curLinearValues[curAdjustItem][4]);
							setTVCurAnologQuantity(curAdjustItem,
									curAnologQuantitys[curAdjustItem]);
//							setTVLinearValues(curAdjustItem, 3,
//									curLinearValues[3]);
							return true;
						}
					}
					return false;
				}
			});

			bt_save = (Button) findViewById(R.id.bt_save);
			bt_save.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
//					if(SystemProperties.get("ro.product.brand", "CHANGHONG").equalsIgnoreCase("BenQ")){
//						saveAndExportBenq();
//					} else {
//					saveAndExport();
					exportlinear();
//					}
				}
			});

			bt_exit = (Button) findViewById(R.id.bt_exit);
			bt_exit.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					showMainWindow(mLayout_linear);
				}
			});

			refreshLinearUI(curSignalChannelIndex, curAdjustItem);
			//applyLinearDataToTV();
		}
		
		private void showAlertDialog(String type) {
			 View view = LayoutInflater.from(mContext).inflate(R.layout.dialogselect, null);
			 RadioGroup rg_select= (RadioGroup) view.findViewById(R.id.rg_dialogselect);
			 if(type.equals("source")) {
				 for(int i=0;i<SourceName.length;i++){
				        RadioButton radioButton=new RadioButton(mContext);
				        radioButton.setId(i);
				        radioButton.setText(SourceName[i]);
				        radioButton.setTextColor(getResources().getColor(R.color.black));
				        rg_select.addView(radioButton);
				        
				    }
					rg_select.check(curSignalChannelIndex);

				    rg_select.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
				        @Override
				        public void onCheckedChanged(RadioGroup group, int checkedId) {
				        	Toast.makeText(mContext, "选择的是: " + checkedId, Toast.LENGTH_LONG).show();
				        	curSignalChannelIndex = checkedId;
							setTVSignalChannel(curSignalChannelIndex);
							refreshLinearUI(curSignalChannelIndex,
									curAdjustItem);
				        }
				    });
			 }else if(type.equals("operation")){
				 String[] list1=getResources().getStringArray(R.array.pq_adjust_item);
				 for(int i=0;i<list1.length;i++){
				        RadioButton radioButton=new RadioButton(mContext);
				        radioButton.setId(i);
				        radioButton.setText(list1[i]);
				        radioButton.setTextColor(getResources().getColor(R.color.black));
				        rg_select.addView(radioButton);
				        
				    }
					rg_select.check(curAdjustItem);

				    rg_select.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
				        @Override
				        public void onCheckedChanged(RadioGroup group, int checkedId) {
				        	Toast.makeText(mContext, "选择的是: " + checkedId, Toast.LENGTH_LONG).show();
							curAdjustItem = checkedId;
							refreshCurAnologQuantity(curPQMode, curAdjustItem);
							refreshLinearUI(curSignalChannelIndex,
									curAdjustItem);
				        }
				    });
			 }
			    


//			 new AlertDialog.Builder(mContext)
//			   .setTitle("please select")
//			   .setView(view)
//			   .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
//			    @Override
//			    public void onClick(DialogInterface dialog, int which) {
//			     dialog.dismiss();
//			    }
//			   })
//			   .show();
			 AlertDialog.Builder myDialogBox = new AlertDialog.Builder(mContext);
	            myDialogBox.setTitle("please select");
	            myDialogBox.setView(view);
	            myDialogBox.setCancelable(false);
//	            myDialogBox.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
//				    @Override
//				    public void onClick(DialogInterface dialog, int which) {
//				     dialog.dismiss();
//				    }
//				   });
	            AlertDialog alertDialog = myDialogBox.create();
	            alertDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
	            	 
	    			@Override
	    			public boolean onKey(DialogInterface dialog, int keyCode,
	    					KeyEvent event) {
	    				if (keyCode == KeyEvent.KEYCODE_BACK) {
	    					dialog.dismiss();
	    				}
	    				return false;
	    			}
	    		});
//	            Window window = alertDialog.getWindow();
	            WindowManager.LayoutParams params =  alertDialog.getWindow().getAttributes();
	            params.width = 250;//WindowManager.LayoutParams.WRAP_CONTENT;
				params.height = WindowManager.LayoutParams.WRAP_CONTENT;
				params.gravity = Gravity.CENTER;
				alertDialog.getWindow().setAttributes(params);
				alertDialog.getWindow().setBackgroundDrawable(getResources().getDrawable(R.drawable.color_brown));
				
//				alertDialog.getWindow().setBackgroundDrawableResource(getResources().getColor(R.color.white));
				alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
	            alertDialog.show();
		}

	//Gets the current brightness, contrast, saturation, clarity, and chromaticity values
		private void initCurAnologQuantity() {
			// TODO Auto-generated method stub

			try {
//				curAnologQuantitys[0] = TVManager
//						.getInstance(NewPQService.this).getPictureManager()
//						.getBrightness();
//				curAnologQuantitys[1] = TVManager
//						.getInstance(NewPQService.this).getPictureManager()
//						.getContrast();
//				curAnologQuantitys[2] = TVManager
//						.getInstance(NewPQService.this).getPictureManager()
//						.getSaturation();
//				curAnologQuantitys[3] = TVManager
//						.getInstance(NewPQService.this).getPictureManager()
//						.getSharpness();
//				curAnologQuantitys[4] = TVManager
//						.getInstance(NewPQService.this).getPictureManager()
//						.getHue();
				
				curAnologQuantitys[0] = MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_BRIGHTNESS);//mTvMiscManager.getBrightness();
				curAnologQuantitys[1] = MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_CONTRAST);//mTvMiscManager.getContrast();
				curAnologQuantitys[2] = MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_SAT);//mTvMiscManager.getSaturation();
				curAnologQuantitys[3] = MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_SHP);//mTvMiscManager.getSharpness();
				curAnologQuantitys[4] = MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_HUE);//mTvMiscManager.getHue();
				Log.v(TAG,"initHue ="+curAnologQuantitys[4]);
				
				String sourceName = MtkTvInputSource.getInstance().getCurrentInputSourceName();
			    NonLinearPqCurve value = MtkTvFApiDisplay.getInstance().getNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.BRIGHTNESS);
			    curLinearValues[0][0] = value.v0;
			    curLinearValues[0][1] = value.v25;
			    curLinearValues[0][2] = value.v50;
			    curLinearValues[0][3] = value.v75;
			    curLinearValues[0][4] = value.v100;
			    Log.i(TAG, "lhtest curLinearValues[0][0]="+curLinearValues[0][0]);
			    value = MtkTvFApiDisplay.getInstance().getNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.CONTRAST);
			    curLinearValues[1][0] = value.v0;
			    curLinearValues[1][1] = value.v25;
			    curLinearValues[1][2] = value.v50;
			    curLinearValues[1][3] = value.v75;
			    curLinearValues[1][4] = value.v100;
			    value = MtkTvFApiDisplay.getInstance().getNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.SATURATION);
			    curLinearValues[2][0] = value.v0;
			    curLinearValues[2][1] = value.v25;
			    curLinearValues[2][2] = value.v50;
			    curLinearValues[2][3] = value.v75;
			    curLinearValues[2][4] = value.v100;
			    value = MtkTvFApiDisplay.getInstance().getNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.SHARPNESS);
			    curLinearValues[3][0] = value.v0;
			    curLinearValues[3][1] = value.v25;
			    curLinearValues[3][2] = value.v50;
			    curLinearValues[3][3] = value.v75;
			    curLinearValues[3][4] = value.v100;
			    value = MtkTvFApiDisplay.getInstance().getNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.HUE);
			    curLinearValues[4][0] = value.v0;
			    curLinearValues[4][1] = value.v25;
			    curLinearValues[4][2] = value.v50;
			    curLinearValues[4][3] = value.v75;
			    curLinearValues[4][4] = value.v100;
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} 
		}

		//In the current source, a current linear dimension, the five INI point set down,
		private void applyLinearDataToTV() {
			// TODO Auto-generated method stub
			// setTVPQMode(getENUMPictureModeFromIndex(curPQMode));
			// refreshCurAnologQuantity(curPQMode, curAdjustItem);

//			int[] values;

//			for (int i = 0; i < 5; i++) {
//				values = getValuesFromString((mStructure.getValue(
//						getSectionName(i),
//						LINEAR_KEY_NAMES[curSignalChannelIndex])));
//				for (int j = 0; j < 5; j++) {
//					setTVLinearValues(i, j, values[j]);
//				}
//			}
			for(int i = 0; i < 5; i++){
				refreshLinearUI(curSignalChannelIndex, i);
			}
		}
		
         //Set linear dimension,Point
		protected void setTVLinearValues(int adjustItem, int curveIndex,
				int value) {
			// TODO Auto-generated method stub
			String sourceName = MtkTvInputSource.getInstance().getCurrentInputSourceName();
			try {
				switch (adjustItem) {
				case 0:
				    NonLinearPqCurve valuetmp0 = MtkTvFApiDisplay.getInstance().getNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.BRIGHTNESS);
				    if(curveIndex == 0){
				    	valuetmp0.v0 = value;
				    } else if(curveIndex == 1){
				    	valuetmp0.v25 = value;
				    } else if(curveIndex == 2){
				    	valuetmp0.v50 = value;
				    } else if(curveIndex == 3){
				    	valuetmp0.v75 = value;
				    } else if(curveIndex == 4){
				    	valuetmp0.v100 = value;
				    }
				    MtkTvFApiDisplay.getInstance().setNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.BRIGHTNESS, valuetmp0, 1);
//					TVManager.getInstance(NewPQService.this).getMiscManager()
//							.setBrightnessCurve(curveIndex, value);
					//less of MTK
//					mTvMiscManager.setBrightnessCurve(curveIndex, value);
					
					break;
				case 1:
					NonLinearPqCurve valuetmp1 = MtkTvFApiDisplay.getInstance().getNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.CONTRAST);
				    if(curveIndex == 0){
				    	valuetmp1.v0 = value;
				    } else if(curveIndex == 1){
				    	valuetmp1.v25 = value;
				    } else if(curveIndex == 2){
				    	valuetmp1.v50 = value;
				    } else if(curveIndex == 3){
				    	valuetmp1.v75 = value;
				    } else if(curveIndex == 4){
				    	valuetmp1.v100 = value;
				    }
				    MtkTvFApiDisplay.getInstance().setNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.CONTRAST, valuetmp1, 1);
//					TVManager.getInstance(NewPQService.this).getMiscManager()
//							.setContrastCurve(curveIndex, value);
					//less of MTK
//					mTvMiscManager.setContrastCurve(curveIndex, value);
					break;
				case 2:
					NonLinearPqCurve valuetmp2 = MtkTvFApiDisplay.getInstance().getNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.SATURATION);
				    if(curveIndex == 0){
				    	valuetmp2.v0 = value;
				    } else if(curveIndex == 1){
				    	valuetmp2.v25 = value;
				    } else if(curveIndex == 2){
				    	valuetmp2.v50 = value;
				    } else if(curveIndex == 3){
				    	valuetmp2.v75 = value;
				    } else if(curveIndex == 4){
				    	valuetmp2.v100 = value;
				    }
				    MtkTvFApiDisplay.getInstance().setNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.SATURATION, valuetmp2, 1);
//					TVManager.getInstance(NewPQService.this).getMiscManager()
//							.setSaturationCurve(curveIndex, value);
					//less of MTK
//					mTvMiscManager.setSaturationCurve(curveIndex, value);
					break;
				case 3:
					NonLinearPqCurve valuetmp3 = MtkTvFApiDisplay.getInstance().getNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.SHARPNESS);
				    if(curveIndex == 0){
				    	valuetmp3.v0 = value;
				    } else if(curveIndex == 1){
				    	valuetmp3.v25 = value;
				    } else if(curveIndex == 2){
				    	valuetmp3.v50 = value;
				    } else if(curveIndex == 3){
				    	valuetmp3.v75 = value;
				    } else if(curveIndex == 4){
				    	valuetmp3.v100 = value;
				    }
				    MtkTvFApiDisplay.getInstance().setNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.SHARPNESS, valuetmp3, 1);
//					TVManager.getInstance(NewPQService.this).getMiscManager()
//							.setSharpnessCurve(curveIndex, value);
					//less of MTK
//					mTvMiscManager.setSharpnessCurve(curveIndex, value);
					break;
				case 4:
					NonLinearPqCurve valuetmp4 = MtkTvFApiDisplay.getInstance().getNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.HUE);
				    if(curveIndex == 0){
				    	valuetmp4.v0 = value;
				    } else if(curveIndex == 1){
				    	valuetmp4.v25 = value;
				    } else if(curveIndex == 2){
				    	valuetmp4.v50 = value;
				    } else if(curveIndex == 3){
				    	valuetmp4.v75 = value;
				    } else if(curveIndex == 4){
				    	valuetmp4.v100 = value;
				    }
				    MtkTvFApiDisplay.getInstance().setNonLinearPqCurve(getCurrentInputSourceType(), NonLinearPqType.HUE, valuetmp4, 1);
//					TVManager.getInstance(NewPQService.this).getMiscManager()
//							.setHueCurve(curveIndex, value);
					//less of MTK
//					mTvMiscManager.setHueCurve(curveIndex, value);
					break;
				default:
					break;
				}
			} catch (Exception e) {
				e.printStackTrace();
			}

		}

		 //Set linear,  Positive
		protected void setTVCurAnologQuantity(int adjustItem, int anologQuantity) {
			// TODO Auto-generated method stub
			Log.d(TAG,"setTVCurAnologQuantity item "+adjustItem+" value "+anologQuantity);
			try {
				switch (adjustItem) {
				case 0:
//					TVManager.getInstance(NewPQService.this)
//							.getPictureManager().setBrightness(anologQuantity);
					MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_BRIGHTNESS, anologQuantity);
//					mTvMiscManager.setBrightness(anologQuantity);
					break;
				case 1:
//					TVManager.getInstance(NewPQService.this)
//							.getPictureManager().setContrast(anologQuantity);
					MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_CONTRAST, anologQuantity);
//					mTvMiscManager.setContrast(anologQuantity);
					break;
				case 2:
//					TVManager.getInstance(NewPQService.this)
//							.getPictureManager().setSaturation(anologQuantity);
					MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_SAT, anologQuantity);
//					mTvMiscManager.setSaturation(anologQuantity);
					break;
				case 3:
//					TVManager.getInstance(NewPQService.this)
//							.getPictureManager().setSharpness(anologQuantity);
					MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_SHP, anologQuantity);
//					mTvMiscManager.setSharpness(anologQuantity);
					break;
				case 4:
//					TVManager.getInstance(NewPQService.this)
//							.getPictureManager().setHue(anologQuantity);
					Log.v(TAG,"setHue="+anologQuantity);
					MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_HUE, anologQuantity);
//					mTvMiscManager.setHue(anologQuantity);
					break;
				default:
					break;
				}
			} catch (Exception e) {
				e.printStackTrace();
			}

		}

		//Interface display
		protected void refreshCurAnologQuantity(int picModeIdx, int adjustItem) {
			// TODO Auto-generated method stub
			bt_curAnologQuantity.setText(getFormatString(getCurAnologQuantity(
					picModeIdx, adjustItem)));

		}

		//Set image mode
		protected void setTVPQMode(int  enumPicMode) {
			// TODO Auto-generated method stub
			try {
				//less of MTK
//				MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_FISION_AUTO_PICTURE, value)
//				mTvMiscManager.setPictureMode(enumPicMode);
//				TVManager.getInstance(NewPQService.this).getPictureManager()
//						.setPictureMode(enumPicMode);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} 
		}
		//less of MTK
//		protected CHENUMPictureMode getENUMPictureModeFromIndex(int idx) {
//			// TODO Auto-generated method stub
//			CHENUMPictureMode tempPicMode = CHENUMPictureMode.CH_PICTURE_MODE_STANDARD;
//			switch (idx) {
//			case 0:
//				tempPicMode = CHENUMPictureMode.CH_PICTURE_MODE_STANDARD;
//				break;
//			case 1:
//				tempPicMode = CHENUMPictureMode.CH_PICTURE_MODE_VIVID;
//				break;
//			case 2:
//				tempPicMode = CHENUMPictureMode.CH_PICTURE_MODE_HOME;
//				break;
//				
//			case 3:
//				tempPicMode = CHENUMPictureMode.CH_PICTURE_MODE_MILD;
//				break;
//			case 4:
//				tempPicMode = CHENUMPictureMode.CH_PICTURE_MODE_USER;
//				break;		
//
//			default:
//				break;
//			}
//			return tempPicMode;
//		}

		private String getFormatString(int value) {
			// TODO Auto-generated method stub
			String retStr;
			if (value < 10) {
				retStr = "" + value + "   ";
			} else if (value < 100) {
				retStr = "" + value + "  ";
			} else {
				retStr = "" + value;
			}
			return "◀ " + retStr + " ▶";
		}

		private int getCurAnologQuantity(int pqmode, int adjustItem) {
			// TODO Auto-generated method stub
			try {
//				switch (pqmode) {
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_STANDARD:
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_MOVIE:
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_UMAX:
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_READING:
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_MV:
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_SPORTS:
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_GAME:
				//case StaticValues.CHTV_CONTEXTUAL_MODEL_FOOTBALL:	
					switch (adjustItem) {
					case 0:
//						return TVManager.getInstance(NewPQService.this)
//								.getPictureManager().getBrightness();
						return MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_BRIGHTNESS);//mTvMiscManager.getBrightness();
					case 1:
//						return TVManager.getInstance(NewPQService.this)
//								.getPictureManager().getContrast();
						return MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_CONTRAST);//mTvMiscManager.getContrast();
					case 2:
//						return TVManager.getInstance(NewPQService.this)
//								.getPictureManager().getSaturation();
						return MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_SAT);//mTvMiscManager.getSaturation();
					case 3:
//						return TVManager.getInstance(NewPQService.this)
//								.getPictureManager().getSharpness();
						return MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_SHP);//mTvMiscManager.getSharpness();
					case 4: 
//						return TVManager.getInstance(NewPQService.this)
//								.getPictureManager().getHue();
//						Log.v(TAG,"getHue="+ mTvMiscManager.getHue());
						return  MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_HUE);//mTvMiscManager.getHue();
					default:
						break;
					}
//					break;
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_USER:
//					switch (adjustItem) {
//					case 0:
//						return curAnologQuantitys[0];
//					case 1:
//						return curAnologQuantitys[1];
//					case 2:
//						return curAnologQuantitys[2];
//					case 3:
//						return curAnologQuantitys[3];
//					case 4:
//						return curAnologQuantitys[4];
//					default:
//						break;
//					}
//					break;
//				default:
//					switch (adjustItem) {
//					case 0:
//						return curAnologQuantitys[0];
//					case 1:
//						return curAnologQuantitys[1];
//					case 2:
//						return curAnologQuantitys[2];
//					case 3:
//						return curAnologQuantitys[3];
//					case 4:
//						return curAnologQuantitys[4];
//					default:
//						break;
//					}					
//					break;
//				}
			} catch (Exception e) {
				e.printStackTrace();
			}

			return 0;
		}

		// When the signal channel is switched, the v0~v100 is refreshed, and the value displayed by the interface is refreshed according to the current adjustment option (whether the current is adjusted brightness or saturation)
		protected void refreshLinearUI(int signalChannelIndex, int adjustItem) {
			// TODO Auto-generated method stub
//			String curValuesStr = mStructure.getValue(
//					getSectionName(adjustItem),
//					LINEAR_KEY_NAMES[signalChannelIndex]);
//			curLinearValues = getValuesFromString(curValuesStr);
			rg_signalChannels.setText(SourceName[signalChannelIndex]+"▶");
			String[] list1=getResources().getStringArray(R.array.pq_adjust_item);
			rg_adjustItem.setText(list1[adjustItem]+"▶");
			NonLinearPqType adjustItemType=NonLinearPqType.BRIGHTNESS;
			if(adjustItem == 0){
				adjustItemType = NonLinearPqType.BRIGHTNESS;
		    } else if(adjustItem == 1){
		    	adjustItemType = NonLinearPqType.CONTRAST;
		    } else if(adjustItem == 2){
		    	adjustItemType = NonLinearPqType.SATURATION;
		    } else if(adjustItem == 3){
		    	adjustItemType = NonLinearPqType.SHARPNESS;
		    } else if(adjustItem == 4){
		    	adjustItemType = NonLinearPqType.HUE;
		    }
			NonLinearPqCurve valuetmp2 = MtkTvFApiDisplay.getInstance().getNonLinearPqCurve(getCurrentInputSourceType(), adjustItemType);
			Log.i(TAG, "lhtest valuetmp2.v0="+valuetmp2.v0);
			bt_v0.setText(getFormatString(valuetmp2.v0));
			tv_v0.setText("(0x" + Integer.toHexString(valuetmp2.v0) + ")");

			bt_v25.setText(getFormatString(valuetmp2.v25));
			tv_v25.setText("(0x" + Integer.toHexString(valuetmp2.v25)
					+ ")");

			bt_v50.setText(getFormatString(valuetmp2.v50));
			tv_v50.setText("(0x" + Integer.toHexString(valuetmp2.v50)
					+ ")");

			bt_v75.setText(getFormatString(valuetmp2.v75));
			tv_v75.setText("(0x" + Integer.toHexString(valuetmp2.v75)
					+ ")");

			bt_v100.setText(getFormatString(valuetmp2.v100));
			tv_v100.setText("(0x" + Integer.toHexString(valuetmp2.v100)
					+ ")");

		}

		private String getSectionName(int adjustItem) {
			// TODO Auto-generated method stub
			switch (adjustItem) {
			case 0:
				return "CHTV_PIC_CURVE_BRI";
			case 1:
				return "CHTV_PIC_CURVE_CNT";
			case 2:
				return "CHTV_PIC_CURVE_SAT";
			case 3:
				return "CHTV_PIC_CURVE_SHP";
			case 4:
				return "CHTV_PIC_CURVE_HUE";
			default:
				break;
			}
			Toast.makeText(mContext, "getSectionName wrong",
					Toast.LENGTH_LONG).show();
			return null;
		}

		// When the sp_signalChannels option changes, set the TV's input source and set the five linear value of the TV based on the value in the current mStructure
		protected boolean setTVSignalChannel(int enumInputSource) {
			// TODO Auto-generated method stub
//			if(enumInputSource == EnumInputSource.E_INPUT_SOURCE_DVI)
//			{
//				enumInputSource = EnumInputSource.E_INPUT_SOURCE_HDMI;
//			}	
			//MODULE
//			if(enumInputSource == EnumInputSource.E_INPUT_SOURCE_HDMI4)
//			{
//				showMessage("Be careful！", "This tool is temporarily unable to cut or cut the signal channel into HDMI-MODULE，Please make sure the MODULE channel is currently in use，Otherwise, switch manually", true);
//			}
//			
//			if(enumInputSource == MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_TV)
//			{
//				showMessage("Be careful！", "This tool is temporarily unable to cut or cut the signal channel to DTV，Please make sure that the DTV channel is currently in use. Otherwise, manually switch", true);
//			}
			if(enumInputSource == 8)//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_RESERVED)
			{
				showMessage("Be careful！", "This tool is temporarily unable to cut or cut the signal channel into USB，Please make sure that the USB channel is currently in use, otherwise manually switch", true);
			}
//			else if(enumInputSource == EnumInputSource.E_INPUT_SOURCE_NETPLAYER)
//			{
//				//showMessage("注意！", "本工具暂时无法使信号通道切到或切出NET，请确保当前已是NET通道，否则请手动切换", true);
//				showMessage("注意！", "本工具内部无法切换，请手动切换", true);
//			}
//			else if(enumInputSource == EnumInputSource.E_INPUT_SOURCE_IPTV)
//			{
//				showMessage("注意！", "本工具暂时无法使信号通道切到或切出IPTV，请确保当前已是IPTV通道，否则请手动切换", true);
//			}
			else
			{
			
//				try {
//							TVManager.getInstance(NewPQService.this).getResourceManager()
//							          .requestResource(EnumResource.CH_RESOURCE_ATV,  "atv");
//						} catch (TVManagerNotInitException e1) {
//							// TODO Auto-generated catch block
//							e1.printStackTrace();
//						}
//					
			
				try {
					enableViews(true);
					
//					Intent tmp = new Intent(Intent.ACTION_VIEW);
//					tmp.addCategory("")
//					tmp.setClassName("com.mediatek.wwtv.tvcenter", "com.mediatek.wwtv.tvcenter.nav.TurnkeyUiMainActivity");
//					tmp.setData(Uri.parse(sourceMap.get(SourceName[enumInputSource])));
//					tmp.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//					startActivity(tmp);
					Intent tmp = new Intent(Intent.ACTION_VIEW);
					tmp.setAction("com.mediatek.select.source");
					tmp.putExtra("com.mediatek.select.sourcename", SourceName[enumInputSource]);
					sendBroadcast(tmp);
//					 mTvMiscManager.startInputSource(0,enumInputSource.ordinal(), -1);
//					MtkTvInputSource.getInstance().changeInputSourcebySourceid(enumInputSource);
//					TVManager.getInstance(NewPQService.this).getSourceManager()
//							.selectInputSource(enumInputSource);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
						showMessage("linear：","the switched signal channel failed. Please switch manually",true);
					//enableViews(false);
					return false;
				}
			}
			

//			if (enumInputSource == EnumInputSource.E_INPUT_SOURCE_ATV) {
//
//				int channelNum = 0;
//				try {
//					
//                  channelNum =mTvChannelManager.getCurrentChannelNumber();
//					
//					
////					channelNum = TVManager.getInstance(mContext)
////							.getATVChannelManager().getCurChannelNum();
//				} catch (Exception e) {
//					// TODO Auto-generated catch block
//					e.printStackTrace();
//					showMessage("error", "getCurChannelNum()fail", true);
//				}
//				try {
//					mTvChannelManager.setAtvChannel(channelNum);
////					TVManager.getInstance(mContext)
////							.getATVPlayer().play(channelNum);
//				} catch (Exception e) {
//					// TODO Auto-generated catch block
//					e.printStackTrace();
//					showMessage("error", "play(channelNum)fail", true);
//				}
//
//			}
//			
//			if(enumInputSource == EnumInputSource.E_INPUT_SOURCE_DTV){
//				mTvChannelManager.playDtvCurrentProgram();
//			}	
//			
			
			

			try {
				byte j = 0;
				int tempValue;
				for (j = 0; j < 5; j++) {
					tempValue = getValueFromString(mStructure.getValue(
							"CHTV_PIC_CURVE_BRI",
							LINEAR_KEY_NAMES[curSignalChannelIndex]), j);
//					TVManager.getInstance(NewPQService.this).getMiscManager()
//							.setBrightnessCurve(j, tempValue);
					//less of MTK
//					mTvMiscManager.setBrightnessCurve(j, tempValue);

					tempValue = getValueFromString(mStructure.getValue(
							"CHTV_PIC_CURVE_CNT",
							LINEAR_KEY_NAMES[curSignalChannelIndex]), j);
//					TVManager.getInstance(NewPQService.this).getMiscManager()
//							.setContrastCurve(j, tempValue);
					//less of MTK
//					mTvMiscManager.setContrastCurve(j, tempValue);

					tempValue = getValueFromString(mStructure.getValue(
							"CHTV_PIC_CURVE_SAT",
							LINEAR_KEY_NAMES[curSignalChannelIndex]), j);
//					TVManager.getInstance(NewPQService.this).getMiscManager()
//							.setSaturationCurve(j, tempValue);
					//less of MTK
//					mTvMiscManager.setSaturationCurve(j, tempValue);

					tempValue = getValueFromString(mStructure.getValue(
							"CHTV_PIC_CURVE_SHP",
							LINEAR_KEY_NAMES[curSignalChannelIndex]), j);
//					TVManager.getInstance(NewPQService.this).getMiscManager()
//							.setSharpnessCurve(j, tempValue);
					//less of MTK
//					mTvMiscManager.setSharpnessCurve(j, tempValue);

					tempValue = getValueFromString(mStructure.getValue(
							"CHTV_PIC_CURVE_HUE",
							LINEAR_KEY_NAMES[curSignalChannelIndex]), j);
//					TVManager.getInstance(NewPQService.this).getMiscManager()
//							.setHueCurve(j, tempValue);
					//less of MTK
//					mTvMiscManager.setHueCurve(j, tempValue);
				}
			} catch (Exception e) {
				e.printStackTrace();
				showMessage("error", "Failed to set signal channel", true);
				return false;
			}
			return true;
		}

		private void enableViews(boolean enabled) {
			// TODO Auto-generated method stub
			rg_adjustItem.setEnabled(enabled);
			rg_adjustItem.setFocusable(enabled);
			bt_v0.setEnabled(enabled);
			bt_v0.setFocusable(enabled);
			bt_v25.setEnabled(enabled);
			bt_v25.setFocusable(enabled);
			bt_v50.setEnabled(enabled);
			bt_v50.setFocusable(enabled);
			bt_v75.setEnabled(enabled);
			bt_v75.setFocusable(enabled);
			bt_v100.setEnabled(enabled);
			bt_v100.setFocusable(enabled);
		}

		// Take a value at the IDX position from a string such as {0,16,53,76,96}
		private int getValueFromString(String str, int idx) {
			String[] values = str.trim().replace("{", "").replace("}", "")
					.split(",");
			int retValue = 0;
			try {
				retValue = Integer.valueOf(values[idx]);
			} catch (Exception e) {
				e.printStackTrace();
				showMessage("error", "data in wrong format", true);
			}
			return retValue;
		}

		private int[] getValuesFromString(String str) {
			int[] retValues = { 0, 0, 0, 0, 0 };
			try{
				String[] values = str.trim().replace("{", "").replace("}", "")
						.split(",");
				
				for (int i = 0; i < values.length; i++) {
					retValues[i] = Integer.valueOf(values[i]);
				}
			}
			catch(Exception e)
			{
				e.printStackTrace();
				showMessage("", getString(R.string.pq_data_format_error_more), true);
			}
			
			return retValues;
		}

		private String getStringFromValues(int[] values) {
			String retStr = "{";
			for (int i = 0; i < values.length; i++) {
				retStr += values[i];
				if (i < values.length - 1) {
					retStr += ",";
				}
			}
			retStr += "}";
			return retStr;
		}

		// Converts the index of the sp_signalChannels to the corresponding TV input source
		private int getEnumInputSourceFromIndex(int idx) {
			// TODO Auto-generated method stub
			byte srcID = (byte) idx;

			int tempSource = 0;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_TV;
			switch (srcID) {
			case StaticValues.CHTV_PIC_ATV_PAL:
			case StaticValues.CHTV_PIC_ATV_NTSC:	
			case StaticValues.CHTV_PIC_ATV_SECAM:	
				tempSource = 0;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_TV;//EnumInputSource.E_INPUT_SOURCE_ATV;
				break;
			case StaticValues.CHTV_PIC_DTV_SD:
			case StaticValues.CHTV_PIC_DTV_HD:
			case StaticValues.CHTV_PIC_DTV_UD:					
				tempSource = 0;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_TV;;//EnumInputSource.E_INPUT_SOURCE_DTV;
				break;
			case StaticValues.CHTV_PIC_AV_PAL:
			case StaticValues.CHTV_PIC_AV_NTSC:
			case StaticValues.CHTV_PIC_AV_SECAM:			
				tempSource = 1;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_COMPOSITE;//EnumInputSource.E_INPUT_SOURCE_CVBS;
				break;
			case StaticValues.CHTV_PIC_YPBPR_SD_I:
			case StaticValues.CHTV_PIC_YPBPR_SD_P:
			case StaticValues.CHTV_PIC_YPBPR_720P:
			case StaticValues.CHTV_PIC_YPBPR_1080I50:
			case StaticValues.CHTV_PIC_YPBPR_1080I60:
			case StaticValues.CHTV_PIC_YPBPR_1080P:
				tempSource = 1;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_COMPOSITE;//EnumInputSource.E_INPUT_SOURCE_YPBPR;
				break;
			case StaticValues.CHTV_PIC_HDMI_SD_I:
			case StaticValues.CHTV_PIC_HDMI_SD_P:
			case StaticValues.CHTV_PIC_HDMI_720P:
			case StaticValues.CHTV_PIC_HDMI_1080I50:
			case StaticValues.CHTV_PIC_HDMI_1080I60:
			case StaticValues.CHTV_PIC_HDMI_1080P:				
			case StaticValues.CHTV_PIC_HDMI_UD:
			case StaticValues.CHTV_PIC_HDMI_VESA:
			case StaticValues.CHTV_PIC_HDMI_HDR:	
			case StaticValues.CHTV_PIC_3D:
			case StaticValues.CHTV_PIC_UMAX_FHD:
			case StaticValues.CHTV_PIC_UMAX_UD:	
				tempSource = 5;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_HDMI;//EnumInputSource.E_INPUT_SOURCE_HDMI;//
				break;
			//case StaticValues.CHTV_PIC_DVI_ON:
			//case StaticValues.CHTV_PIC_DVI_OFF:
			//	tempSource = EnumInputSource.E_INPUT_SOURCE_DVI;
			//	break;
			case StaticValues.CHTV_PIC_VGA:
				tempSource = 6;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_VGA;//EnumInputSource.E_INPUT_SOURCE_VGA;
				break;
			case StaticValues.CHTV_PIC_MMP_SD:
			case StaticValues.CHTV_PIC_MMP_HD:
			case StaticValues.CHTV_PIC_MMP_UD:
			case StaticValues.CHTV_PIC_MMP_HDR:
				tempSource = 7;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_RESERVED;//EnumInputSource.E_INPUT_SOURCE_STORAGE;
				break;
			case StaticValues.CHTV_PIC_NET_SD:
			case StaticValues.CHTV_PIC_NET_HD:
			case StaticValues.CHTV_PIC_NET_UD:
			case StaticValues.CHTV_PIC_NET_HDR:					
				tempSource = 7;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_RESERVED;//EnumInputSource.E_INPUT_SOURCE_STORAGE;
				break;
			case StaticValues.CHTV_PIC_RESERVED1:
			case StaticValues.CHTV_PIC_RESERVED2:	
				tempSource = 0;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_TV;//EnumInputSource.E_INPUT_SOURCE_STORAGE;
				break;
			case StaticValues.CHTV_PIC_M_FHD:
			case StaticValues.CHTV_PIC_M_UD:	
			    tempSource = 5;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_HDMI;//EnumInputSource.E_INPUT_SOURCE_STORAGE;//EnumInputSource.E_INPUT_SOURCE_HDMI3;//E_INPUT_SOURCE_MODULE;	
				break;
			default:
				break;

			}
			return tempSource;
		}
		
		@Override
		public boolean dispatchKeyEvent(KeyEvent event) {
			// TODO Auto-generated method stub
			if (event.getAction() == KeyEvent.ACTION_DOWN) {
				switch (event.getKeyCode()) {
				case KeyEvent.KEYCODE_BACK:
					showMainWindow(mLayout_linear);
					return true;
				}
			}
			return super.dispatchKeyEvent(event);
		}

	}
 
	class PQLayout_Linear_Benq extends LinearLayout{

//		Spinner sp_signalChannels, sp_pqMode, sp_adjustItem;
//		LinearLayout ll_brightness, ll_contrast, ll_saturation, ll_sharpness,
//				ll_hue;

		Button bt_curAnologQuantity, bt_v0, bt_v25, bt_v50, bt_v75, bt_v100;
		TextView tv_v0, tv_v25, tv_v50, tv_v75; //tv_v100;
//		int curSignalChannelIndex = 0;
//		int curPQMode = 0;
//		int curAdjustItem = 0;
//		int[] curAnologQuantitys = { 0, 0, 0, 0, 0 };// Each adjustment option corresponds to one
		int[] curLinearValues = { 0, 0, 0, 0, 0 };// The value of the v0~v100 corresponding to the current tuning option
		boolean bSpinnerPQModeHasFocus = false;
		boolean bCenterPressed = false;

		Button bt_save, bt_exit;

		public PQLayout_Linear_Benq(Context context) {
			super(context);
			// TODO Auto-generated constructor stub
			mInflater.inflate(R.layout.pq_linear_benq, this);


			String curValuesStr = mStructure.getValue(
					"CHTV_LIGHTSENSOR_BENQ",
					"LIGHTSENSOR_LINEAR");
			Log.d(TAG,"----- curValuesStr ---"+curValuesStr);
			curLinearValues = getValuesFromString(curValuesStr);

			bt_curAnologQuantity = (Button) findViewById(R.id.bt_curAnologQuantity);
			bt_curAnologQuantity.setNextFocusLeftId(bt_curAnologQuantity
					.getId());
			bt_curAnologQuantity.setNextFocusRightId(bt_curAnologQuantity
					.getId());
			bt_curAnologQuantity
					.setText("◀"+curLinearValues[0]+"▶");
			bt_curAnologQuantity.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							bCenterPressed = false;

							if(curLinearValues[0] > 0){
								curLinearValues[0] = curLinearValues[0] -1;
//								TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
							}
							mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							bt_curAnologQuantity.setText("◀"+curLinearValues[0]+"▶");
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							bCenterPressed = false;
							if(curLinearValues[0] < curLinearValues[1]){
								curLinearValues[0] = curLinearValues[0] + 1;
//								TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
							}
							mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							bt_curAnologQuantity.setText("◀"+curLinearValues[0]+"▶");
							return true;
						case KeyEvent.KEYCODE_DPAD_CENTER:
					//		if (curPQMode != StaticValues.CHTV_CONTEXTUAL_MODEL_USER) {
								bSpinnerPQModeHasFocus = false;
//								sp_pqMode.setSelection(0, true);
					//		}
						    if(curLinearValues[0] < curLinearValues[1] + 10){
							    curLinearValues[0] += 10;
//							TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
						    }
						    mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							bt_curAnologQuantity.setText("◀"+curLinearValues[0]+"▶");

							return true;
						default:
							break;
						}

					}
					return false;
				}
			});

			bt_v0 = (Button) findViewById(R.id.bt_v0);
			tv_v0 = (TextView) findViewById(R.id.tv_v0);
			bt_v0.setNextFocusLeftId(bt_v0.getId());
			bt_v0.setNextFocusRightId(bt_v0.getId());
			bt_v0.setText("◀"+curLinearValues[1]+"▶");
			bt_v0.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if(curLinearValues[1] -1 > curLinearValues[0]){
								curLinearValues[1] = curLinearValues[1] -1;
//								TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
							}
							mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							bt_v0.setText("◀"+curLinearValues[1]+"▶");
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							
							if( curLinearValues[1] + 1 < curLinearValues[2]){
								curLinearValues[1] = curLinearValues[1] +1;
//								TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
							}
							mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							bt_v0.setText("◀"+curLinearValues[1]+"▶");
							return true;
						case KeyEvent.KEYCODE_DPAD_CENTER:
							if( curLinearValues[1] + 10 < curLinearValues[2]){
								curLinearValues[1] = curLinearValues[1] +10;
//								TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
							}
							mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							bt_v0.setText("◀"+curLinearValues[1]+"▶");						
							break;
						}
					}
					return false;
				}
			});

			bt_v25 = (Button) findViewById(R.id.bt_v25);
			tv_v25 = (TextView) findViewById(R.id.tv_v25);
			bt_v25.setNextFocusLeftId(bt_v25.getId());
			bt_v25.setNextFocusRightId(bt_v25.getId());
			bt_v25.setText("◀"+curLinearValues[2]+"▶");
			bt_v25.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if(curLinearValues[2] -1 > curLinearValues[1]){
								curLinearValues[2] = curLinearValues[2] -1;
//								TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
							}
							mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							bt_v25.setText("◀"+curLinearValues[2]+"▶");
							
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if( curLinearValues[2] + 1 < curLinearValues[3]){
								curLinearValues[2] = curLinearValues[2] +1;
//								TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
							}
							mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							bt_v25.setText("◀"+curLinearValues[2]+"▶");
							return true;
						case KeyEvent.KEYCODE_DPAD_CENTER:
							if( curLinearValues[2] + 10 < curLinearValues[3]){
								curLinearValues[2] = curLinearValues[2] +10;
//								TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
							}
							mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							bt_v25.setText("◀"+curLinearValues[2]+"▶");
							break;
						}
					}
					return false;
				}
			});

			bt_v50 = (Button) findViewById(R.id.bt_v50);
			tv_v50 = (TextView) findViewById(R.id.tv_v50);
			bt_v50.setNextFocusLeftId(bt_v50.getId());
			bt_v50.setNextFocusRightId(bt_v50.getId());
			bt_v50.setText("◀"+curLinearValues[3]+"▶");
			bt_v50.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if(curLinearValues[3] -1 > curLinearValues[2]){
								curLinearValues[3] = curLinearValues[3] -1;
//								TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
							}
							mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							bt_v50.setText("◀"+curLinearValues[3]+"▶");
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if( curLinearValues[3] + 1 < curLinearValues[4]){
								curLinearValues[3] = curLinearValues[3] +1;
//								TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
							}
							mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							bt_v50.setText("◀"+curLinearValues[3]+"▶");
							return true;
						case KeyEvent.KEYCODE_DPAD_CENTER:
							if( curLinearValues[3] + 10 < curLinearValues[4]){
								curLinearValues[3] = curLinearValues[3] +10;
//								TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
							}
							mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							bt_v50.setText("◀"+curLinearValues[3]+"▶");
							
							break;
						}
					}
					return false;
				}
			});

			bt_v75 = (Button) findViewById(R.id.bt_v75);
			tv_v75 = (TextView) findViewById(R.id.tv_v75);
			bt_v75.setNextFocusLeftId(bt_v75.getId());
			bt_v75.setNextFocusRightId(bt_v75.getId());
			bt_v75.setText("◀"+curLinearValues[4]+"▶");
			bt_v75.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if(curLinearValues[4] -1 > curLinearValues[3]){
								curLinearValues[4] = curLinearValues[4] -1;
//								TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
							}
							mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							bt_v75.setText("◀"+curLinearValues[4]+"▶");
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
								curLinearValues[4] = curLinearValues[4] +1;
//								TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
							bt_v75.setText("◀"+curLinearValues[4]+"▶");
							mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							return true;
						case KeyEvent.KEYCODE_DPAD_CENTER:
								curLinearValues[3] = curLinearValues[3] +10;
//								TvMiscManager.getInstance().setNLA_LightSenor(curLinearValues[0], curLinearValues[1], curLinearValues[2], curLinearValues[3], curLinearValues[4]);
							bt_v75.setText("◀"+curLinearValues[4]+"▶");
							mStructure.setValue("CHTV_LIGHTSENSOR_BENQ",
									"LIGHTSENSOR_LINEAR",
									getStringFromValues(curLinearValues));
							return true;
						}
					}
					return false;
				}
			});

//			bt_v100 = (Button) findViewById(R.id.bt_v100);
//			tv_v100 = (TextView) findViewById(R.id.tv_v100);
//			bt_v100.setNextFocusLeftId(bt_v100.getId());
//			bt_v100.setNextFocusRightId(bt_v100.getId());
//			bt_v100.setOnKeyListener(new OnKeyListener() {
//
//				@Override
//				public boolean onKey(View v, int keyCode, KeyEvent event) {
//					// TODO Auto-generated method stub
//					if (event.getAction() == KeyEvent.ACTION_DOWN) {
//						switch (keyCode) {
//						case KeyEvent.KEYCODE_DPAD_LEFT:
//							if(curLinearValues[4] == 0)
//							{
//								curLinearValues[4] = 255;
//							}
//							else
//							{
//								curLinearValues[4] -= 1;
//								if (curLinearValues[4] < 0) {
//									curLinearValues[4] = 0;
//								}
//							}
//							curLinearValues[3] = (curLinearValues[2] + curLinearValues[4]) / 2;
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
//							bt_v100.setText(getFormatString(curLinearValues[4]));
//							tv_v100.setText("(0x"
//									+ Integer.toHexString(curLinearValues[4])
//									+ ")");
//							bt_v75.setText(getFormatString(curLinearValues[3]));
//							tv_v75.setText("(0x"
//									+ Integer.toHexString(curLinearValues[3])
//									+ ")");
//							setTVLinearValues(curAdjustItem, 4,
//									curLinearValues[4]);
//							setTVLinearValues(curAdjustItem, 3,
//									curLinearValues[3]);
//							return true;
//						case KeyEvent.KEYCODE_DPAD_RIGHT:
//							if(curLinearValues[4] == 255)
//							{
//								curLinearValues[4] = 0;
//							}
//							else
//							{
//								curLinearValues[4] += 1;
//								if (curLinearValues[4] > 255) {
//									curLinearValues[4] = 255;
//								}
//							}
//							curLinearValues[3] = (curLinearValues[2] + curLinearValues[4]) / 2;
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
//							bt_v100.setText(getFormatString(curLinearValues[4]));
//							tv_v100.setText("(0x"
//									+ Integer.toHexString(curLinearValues[4])
//									+ ")");
//							bt_v75.setText(getFormatString(curLinearValues[3]));
//							tv_v75.setText("(0x"
//									+ Integer.toHexString(curLinearValues[3])
//									+ ")");
//							setTVLinearValues(curAdjustItem, 4,
//									curLinearValues[4]);
//							setTVLinearValues(curAdjustItem, 3,
//									curLinearValues[3]);
//							return true;
//						case KeyEvent.KEYCODE_DPAD_CENTER:
//							if(curLinearValues[4] == 255)
//							{
//								curLinearValues[4] = 0;
//							}
//							else
//							{
//								curLinearValues[4] += 10;
//								if (curLinearValues[4] > 255) {
//									curLinearValues[4] = 255;
//								}
//							}
//							curLinearValues[3] = (curLinearValues[2] + curLinearValues[4]) / 2;
//							mStructure.setValue(getSectionName(curAdjustItem),
//									LINEAR_KEY_NAMES[curSignalChannelIndex],
//									getStringFromValues(curLinearValues));
//							bt_v100.setText(getFormatString(curLinearValues[4]));
//							tv_v100.setText("(0x"
//									+ Integer.toHexString(curLinearValues[4])
//									+ ")");
//							bt_v75.setText(getFormatString(curLinearValues[3]));
//							tv_v75.setText("(0x"
//									+ Integer.toHexString(curLinearValues[3])
//									+ ")");
//							setTVLinearValues(curAdjustItem, 4,
//									curLinearValues[4]);
//							setTVLinearValues(curAdjustItem, 3,
//									curLinearValues[3]);
//							return true;
//						}
//					}
//					return false;
//				}
//			});

			bt_save = (Button) findViewById(R.id.bt_save);
			bt_save.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					saveAndExportBenq();
				}
			});

			bt_exit = (Button) findViewById(R.id.bt_exit);
			bt_exit.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					showMainWindow(mLayout_linear_benq);
				}
			});

		}


		



		//Set image mode
		protected void setTVPQMode(int  enumPicMode) {
			// TODO Auto-generated method stub
			try {
				MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_TEMP , enumPicMode);
//				mTvMiscManager.setPictureMode(enumPicMode);
//				TVManager.getInstance(NewPQService.this).getPictureManager()
//						.setPictureMode(enumPicMode);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} 
		}

		protected int getENUMPictureModeFromIndex(int idx) {
			// TODO Auto-generated method stub
			int tempPicMode = MtkTvConfigTypeBase.VID_CLR_TEMP_USER;
			switch (idx) {
			case 0:
				tempPicMode = MtkTvConfigTypeBase.VID_CLR_TEMP_WARM;
				break;
			case 1:
				tempPicMode = MtkTvConfigTypeBase.VID_CLR_TEMP_STANDARD;
				break;
			case 2:
				tempPicMode = MtkTvConfigTypeBase.VID_CLR_TEMP_COOL;
				break;
				
			case 3:
				tempPicMode = MtkTvConfigTypeBase.VID_CLR_TEMP_USER;
				break;
			case 4:
//				tempPicMode = CHENUMPictureMode.CH_PICTURE_MODE_USER;
				break;		

			default:
				break;
			}
			return tempPicMode;
		}

		private String getFormatString(int value) {
			// TODO Auto-generated method stub
			String retStr;
			if (value < 10) {
				retStr = "" + value + "   ";
			} else if (value < 100) {
				retStr = "" + value + "  ";
			} else {
				retStr = "" + value;
			}
			return "◀ " + retStr + " ▶";
		}

		private int getCurAnologQuantity(int pqmode, int adjustItem) {
			// TODO Auto-generated method stub
			try {
//				switch (pqmode) {
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_STANDARD:
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_MOVIE:
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_UMAX:
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_READING:
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_MV:
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_SPORTS:
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_GAME:
				//case StaticValues.CHTV_CONTEXTUAL_MODEL_FOOTBALL:	
					switch (adjustItem) {
					case 0:
//						return TVManager.getInstance(NewPQService.this)
//								.getPictureManager().getBrightness();
						return MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_BRIGHTNESS);//mTvMiscManager.getBrightness();
					case 1:
//						return TVManager.getInstance(NewPQService.this)
//								.getPictureManager().getContrast();
						return MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_CONTRAST);//mTvMiscManager.getContrast();
					case 2:
//						return TVManager.getInstance(NewPQService.this)
//								.getPictureManager().getSaturation();
						return MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_SAT);//mTvMiscManager.getSaturation();
					case 3:
//						return TVManager.getInstance(NewPQService.this)
//								.getPictureManager().getSharpness();
						return MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_SHP);//mTvMiscManager.getSharpness();
					case 4: 
//						return TVManager.getInstance(NewPQService.this)
//								.getPictureManager().getHue();
//						Log.v(TAG,"getHue="+ mTvMiscManager.getHue());
						return  MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_VID_HUE);//mTvMiscManager.getHue();
					default:
						break;
					}
//					break;
//				case StaticValues.CHTV_CONTEXTUAL_MODEL_USER:
//					switch (adjustItem) {
//					case 0:
//						return curAnologQuantitys[0];
//					case 1:
//						return curAnologQuantitys[1];
//					case 2:
//						return curAnologQuantitys[2];
//					case 3:
//						return curAnologQuantitys[3];
//					case 4:
//						return curAnologQuantitys[4];
//					default:
//						break;
//					}
//					break;
//				default:
//					switch (adjustItem) {
//					case 0:
//						return curAnologQuantitys[0];
//					case 1:
//						return curAnologQuantitys[1];
//					case 2:
//						return curAnologQuantitys[2];
//					case 3:
//						return curAnologQuantitys[3];
//					case 4:
//						return curAnologQuantitys[4];
//					default:
//						break;
//					}					
//					break;
//				}
			} catch (Exception e) {
				e.printStackTrace();
			}

			return 0;
		}

		// When the signal channel is switched, the v0~v100 is refreshed, and the value displayed by the interface is refreshed according to the current adjustment option (whether the current is adjusted brightness or saturation)
		protected void refreshLinearUI(int signalChannelIndex, int adjustItem) {
			// TODO Auto-generated method stub
			String curValuesStr = mStructure.getValue(
					getSectionName(adjustItem),
					LINEAR_KEY_NAMES[signalChannelIndex]);
			curLinearValues = getValuesFromString(curValuesStr);

			bt_v0.setText(getFormatString(curLinearValues[0]));
			tv_v0.setText("(0x" + Integer.toHexString(curLinearValues[0]) + ")");

			bt_v25.setText(getFormatString(curLinearValues[1]));
			tv_v25.setText("(0x" + Integer.toHexString(curLinearValues[1])
					+ ")");

			bt_v50.setText(getFormatString(curLinearValues[2]));
			tv_v50.setText("(0x" + Integer.toHexString(curLinearValues[2])
					+ ")");

			bt_v75.setText(getFormatString(curLinearValues[3]));
			tv_v75.setText("(0x" + Integer.toHexString(curLinearValues[3])
					+ ")");

//			bt_v100.setText(getFormatString(curLinearValues[4]));
//			tv_v100.setText("(0x" + Integer.toHexString(curLinearValues[4])
//					+ ")");

		}

		private String getSectionName(int adjustItem) {
			// TODO Auto-generated method stub
			switch (adjustItem) {
			case 0:
				return "CHTV_PIC_CURVE_BRI";
			case 1:
				return "CHTV_PIC_CURVE_CNT";
			case 2:
				return "CHTV_PIC_CURVE_SAT";
			case 3:
				return "CHTV_PIC_CURVE_SHP";
			case 4:
				return "CHTV_PIC_CURVE_HUE";
			default:
				break;
			}
			Toast.makeText(mContext, "getSectionName wrong",
					Toast.LENGTH_LONG).show();
			return null;
		}

		// When the sp_signalChannels option changes, set the TV's input source and set the five linear value of the TV based on the value in the current mStructure

		private void enableViews(boolean enabled) {
			// TODO Auto-generated method stub
			bt_v0.setEnabled(enabled);
			bt_v0.setFocusable(enabled);
			bt_v25.setEnabled(enabled);
			bt_v25.setFocusable(enabled);
			bt_v50.setEnabled(enabled);
			bt_v50.setFocusable(enabled);
			bt_v75.setEnabled(enabled);
			bt_v75.setFocusable(enabled);
			bt_v100.setEnabled(enabled);
			bt_v100.setFocusable(enabled);
		}

		// Take a value at the IDX position from a string such as {0,16,53,76,96}
		private int getValueFromString(String str, int idx) {
			String[] values = str.trim().replace("{", "").replace("}", "")
					.split(",");
			int retValue = 0;
			try {
				retValue = Integer.valueOf(values[idx]);
			} catch (Exception e) {
				e.printStackTrace();
				showMessage("error", "data in wrong format", true);
			}
			return retValue;
		}

		private int[] getValuesFromString(String str) {
			int[] retValues = { 0, 0, 0, 0, 0 };
			try{
				String[] values = str.trim().replace("{", "").replace("}", "")
						.split(",");
				
				for (int i = 0; i < values.length; i++) {
					retValues[i] = Integer.valueOf(values[i]);
				}
			}
			catch(Exception e)
			{
				e.printStackTrace();
				showMessage("", getString(R.string.pq_data_format_error_more), true);
			}
			
			return retValues;
		}

		private String getStringFromValues(int[] values) {
			String retStr = "{";
			for (int i = 0; i < values.length; i++) {
				retStr += values[i];
				if (i < values.length - 1) {
					retStr += ",";
				}
			}
			retStr += "}";
			return retStr;
		}

		// Converts the index of the sp_signalChannels to the corresponding TV input source
		private int getEnumInputSourceFromIndex(int idx) {
			// TODO Auto-generated method stub
			byte srcID = (byte) idx;

			int tempSource = 0;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_TV;//EnumInputSource.E_INPUT_SOURCE_ATV;
			switch (srcID) {
			case StaticValues.CHTV_PIC_ATV_PAL:
			case StaticValues.CHTV_PIC_ATV_NTSC:	
			case StaticValues.CHTV_PIC_ATV_SECAM:	
				tempSource = 0;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_TV;//EnumInputSource.E_INPUT_SOURCE_ATV;
				break;
			case StaticValues.CHTV_PIC_DTV_SD:
			case StaticValues.CHTV_PIC_DTV_HD:
			case StaticValues.CHTV_PIC_DTV_UD:					
				tempSource = 0;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_TV;//EnumInputSource.E_INPUT_SOURCE_DTV;
				break;
			case StaticValues.CHTV_PIC_AV_PAL:
			case StaticValues.CHTV_PIC_AV_NTSC:
			case StaticValues.CHTV_PIC_AV_SECAM:			
				tempSource = 1;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_COMPOSITE;//EnumInputSource.E_INPUT_SOURCE_CVBS;
				break;
			case StaticValues.CHTV_PIC_YPBPR_SD_I:
			case StaticValues.CHTV_PIC_YPBPR_SD_P:
			case StaticValues.CHTV_PIC_YPBPR_720P:
			case StaticValues.CHTV_PIC_YPBPR_1080I50:
			case StaticValues.CHTV_PIC_YPBPR_1080I60:
			case StaticValues.CHTV_PIC_YPBPR_1080P:
				tempSource = 4;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_COMPONENT;//EnumInputSource.E_INPUT_SOURCE_YPBPR;
				break;
			case StaticValues.CHTV_PIC_HDMI_SD_I:
			case StaticValues.CHTV_PIC_HDMI_SD_P:
			case StaticValues.CHTV_PIC_HDMI_720P:
			case StaticValues.CHTV_PIC_HDMI_1080I50:
			case StaticValues.CHTV_PIC_HDMI_1080I60:
			case StaticValues.CHTV_PIC_HDMI_1080P:				
			case StaticValues.CHTV_PIC_HDMI_UD:
			case StaticValues.CHTV_PIC_HDMI_VESA:
			case StaticValues.CHTV_PIC_HDMI_HDR:	
			case StaticValues.CHTV_PIC_3D:
			case StaticValues.CHTV_PIC_UMAX_FHD:
			case StaticValues.CHTV_PIC_UMAX_UD:	
				tempSource = 5;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_HDMI;//EnumInputSource.E_INPUT_SOURCE_HDMI;//
				break;
			//case StaticValues.CHTV_PIC_DVI_ON:
			//case StaticValues.CHTV_PIC_DVI_OFF:
			//	tempSource = EnumInputSource.E_INPUT_SOURCE_DVI;
			//	break;
			case StaticValues.CHTV_PIC_VGA:
				tempSource = 6;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_VGA;//EnumInputSource.E_INPUT_SOURCE_VGA;
				break;
			case StaticValues.CHTV_PIC_MMP_SD:
			case StaticValues.CHTV_PIC_MMP_HD:
			case StaticValues.CHTV_PIC_MMP_UD:
			case StaticValues.CHTV_PIC_MMP_HDR:
				tempSource = 8;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_RESERVED;//EnumInputSource.E_INPUT_SOURCE_STORAGE;
				break;
			case StaticValues.CHTV_PIC_NET_SD:
			case StaticValues.CHTV_PIC_NET_HD:
			case StaticValues.CHTV_PIC_NET_UD:
			case StaticValues.CHTV_PIC_NET_HDR:					
				tempSource = 8;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_RESERVED;//EnumInputSource.E_INPUT_SOURCE_STORAGE;
				break;
			case StaticValues.CHTV_PIC_RESERVED1:
			case StaticValues.CHTV_PIC_RESERVED2:	
				tempSource = 0;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_TV;//EnumInputSource.E_INPUT_SOURCE_ATV;
				break;
			case StaticValues.CHTV_PIC_M_FHD:
			case StaticValues.CHTV_PIC_M_UD:	
			    tempSource = 5;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_HDMI;//EnumInputSource.E_INPUT_SOURCE_HDMI3;//E_INPUT_SOURCE_MODULE;	
				break;
			default:
				break;

			}
			return tempSource;
		}
		
		@Override
		public boolean dispatchKeyEvent(KeyEvent event) {
			// TODO Auto-generated method stub
			if (event.getAction() == KeyEvent.ACTION_DOWN) {
				switch (event.getKeyCode()) {
				case KeyEvent.KEYCODE_BACK:
					showMainWindow(mLayout_linear_benq);
					return true;
				}
			}
			return super.dispatchKeyEvent(event);
		}
	}
	
	
	class PQLayout_Color extends LinearLayout {
        
		Button  rg_signalChannels_color;
		Button rg_colorMode;
		Button bt_rGain, bt_gGain, bt_bGain, bt_rOffset, bt_gOffset,
				bt_bOffset, bt_backLight;
		int curSignalChannelIndex, curColorModeIndex;
		//int[] curColorValues = { 0, 0, 0, 0, 0, 0, 0};
		int[] curColorValues = { 0, 0, 0, 0, 0, 0};
		Button bt_save, bt_exit;

		public PQLayout_Color(Context context) {
			super(context);
			// TODO Auto-generated constructor stub
			mInflater.inflate(R.layout.pq_color, this);

			rg_signalChannels_color = (Button) findViewById(R.id.rg_signalChannels_color);
			curSignalChannelIndex = getCurrentSignalChannel(true);
			rg_signalChannels_color.setText(SourceName[curSignalChannelIndex]+"▶");

			rg_signalChannels_color.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_UP) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_RIGHT:
						case KeyEvent.KEYCODE_DPAD_CENTER:	 
							try {
								showAlertDialog1("source");

							    } catch (Exception e) {
								   
							    }
							
							return true;
						
						}
					}

					return false;
				}
			});



			rg_colorMode = (Button) findViewById(R.id.rg_colorMode);

			String[] list1=getResources().getStringArray(R.array.pq_color_mode);
			curColorModeIndex = getCurrentContextualModeIndex();
			rg_colorMode.setText(list1[curColorModeIndex]+"▶");

			rg_colorMode.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_UP) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_RIGHT:
						case KeyEvent.KEYCODE_DPAD_CENTER:	 
							try {
								showAlertDialog1("colormode");

							    } catch (Exception e) {
								   
							    }
							
							return true;
						
						}
					}

					return false;
				}
			});


//			MySpinnerAdapter adapter_colorMode = new MySpinnerAdapter(
//					mContext, R.layout.pq_spinner_item,
//					getResources().getStringArray(R.array.pq_color_mode));
//			sp_colorMode.setAdapter(adapter_colorMode);
//			curColorModeIndex = getCurrentContextualModeIndex();			
//			sp_colorMode.setSelection(curColorModeIndex, true);
//			sp_colorMode
//					.setOnItemSelectedListener(new OnItemSelectedListener() {
//
//						@Override
//						public void onItemSelected(AdapterView<?> parent,
//								View v, int position, long id) {
//							// TODO Auto-generated method stub
//							Log.i(TAG, "lhtest 333");
//							curColorModeIndex = position;
//							setTVContextualModel(curColorModeIndex);
//							curColorValues = getCurrentColorValues(
//									curSignalChannelIndex, curColorModeIndex);
//							refreshColorUI(curColorValues);
//							setTVColor(curColorValues);
//						}
//
//						@Override
//						public void onNothingSelected(AdapterView<?> arg0) {
//							// TODO Auto-generated method stub
//							Log.i(TAG, "lhtest 444");
//						}
//					});

			curColorValues = getCurrentColorValues(curSignalChannelIndex,
					curColorModeIndex);
			bt_rGain = (Button) findViewById(R.id.bt_rGain);
			bt_rGain.setNextFocusLeftId(bt_rGain.getId());
			bt_rGain.setNextFocusRightId(bt_rGain.getId());
			bt_rGain.setText(getFormatString(curColorValues[0]));
			bt_rGain.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if (curColorValues[0] > colortempMin) {
								curColorValues[0] -= 1;
								if (curColorValues[0] < colortempMin) {
									curColorValues[0] = colortempMin;
								}
							}
							bt_rGain.setText(getFormatString(curColorValues[0]));
							mStructure.setValue(
									getSectionName(curSignalChannelIndex),
									COLOR_KEY_NAMES[curColorModeIndex],
									getStringFromValues(curColorValues));
							setTVColorTempGain(curColorValues[0],
									curColorValues[1], curColorValues[2]);
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if (curColorValues[0] < colortempMax) {
								curColorValues[0] += 1;
								if (curColorValues[0] > colortempMax) {
									curColorValues[0] = colortempMax;
								}
							}
							bt_rGain.setText(getFormatString(curColorValues[0]));
							mStructure.setValue(
									getSectionName(curSignalChannelIndex),
									COLOR_KEY_NAMES[curColorModeIndex],
									getStringFromValues(curColorValues));
							setTVColorTempGain(curColorValues[0],
									curColorValues[1], curColorValues[2]);
							return true;
						default:
							return false;
						}
					}
					return false;
				}
			});

			bt_gGain = (Button) findViewById(R.id.bt_gGain);
			bt_gGain.setNextFocusLeftId(bt_gGain.getId());
			bt_gGain.setNextFocusRightId(bt_gGain.getId());
			bt_gGain.setText(getFormatString(curColorValues[1]));
			bt_gGain.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if (curColorValues[1] > colortempMin) {
								curColorValues[1] -= 1;
								if (curColorValues[1] < colortempMin) {
									curColorValues[1] = colortempMin;
								}
							}
							bt_gGain.setText(getFormatString(curColorValues[1]));
							mStructure.setValue(
									getSectionName(curSignalChannelIndex),
									COLOR_KEY_NAMES[curColorModeIndex],
									getStringFromValues(curColorValues));
							setTVColorTempGain(curColorValues[0],
									curColorValues[1], curColorValues[2]);
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if (curColorValues[1] < colortempMax) {
								curColorValues[1] += 1;
								if (curColorValues[1] > colortempMax) {
									curColorValues[1] = colortempMax;
								}
							}
							bt_gGain.setText(getFormatString(curColorValues[1]));
							mStructure.setValue(
									getSectionName(curSignalChannelIndex),
									COLOR_KEY_NAMES[curColorModeIndex],
									getStringFromValues(curColorValues));
							setTVColorTempGain(curColorValues[0],
									curColorValues[1], curColorValues[2]);
							return true;
						default:
							return false;
						}
					}
					return false;
				}
			});

			bt_bGain = (Button) findViewById(R.id.bt_bGain);
			bt_bGain.setNextFocusLeftId(bt_bGain.getId());
			bt_bGain.setNextFocusRightId(bt_bGain.getId());
			bt_bGain.setText(getFormatString(curColorValues[2]));
			bt_bGain.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if (curColorValues[2] > colortempMin) {
								curColorValues[2] -= 1;
								if (curColorValues[2] < colortempMin) {
									curColorValues[2] = colortempMin;
								}
							}
							bt_bGain.setText(getFormatString(curColorValues[2]));
							mStructure.setValue(
									getSectionName(curSignalChannelIndex),
									COLOR_KEY_NAMES[curColorModeIndex],
									getStringFromValues(curColorValues));
							setTVColorTempGain(curColorValues[0],
									curColorValues[1], curColorValues[2]);
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if (curColorValues[2] < colortempMax) {
								curColorValues[2] += 1;
								if (curColorValues[2] > colortempMax) {
									curColorValues[2] = colortempMax;
								}
							}
							bt_bGain.setText(getFormatString(curColorValues[2]));
							mStructure.setValue(
									getSectionName(curSignalChannelIndex),
									COLOR_KEY_NAMES[curColorModeIndex],
									getStringFromValues(curColorValues));
							setTVColorTempGain(curColorValues[0],
									curColorValues[1], curColorValues[2]);
							return true;
						default:
							return false;
						}
					}
					return false;
				}
			});

			bt_rOffset = (Button) findViewById(R.id.bt_rOffset);
			bt_rOffset.setNextFocusLeftId(bt_rOffset.getId());
			bt_rOffset.setNextFocusRightId(bt_rOffset.getId());
			bt_rOffset.setText(getFormatString(curColorValues[3]));
			bt_rOffset.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if (curColorValues[3] > colortempMin) {
								curColorValues[3] -= 1;
								if (curColorValues[3] < colortempMin) {
									curColorValues[3] = colortempMin;
								}
							}
							bt_rOffset
									.setText(getFormatString(curColorValues[3]));
							mStructure.setValue(
									getSectionName(curSignalChannelIndex),
									COLOR_KEY_NAMES[curColorModeIndex],
									getStringFromValues(curColorValues));
							setTVColorTempOffset(curColorValues[3],
									curColorValues[4], curColorValues[5]);
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if (curColorValues[3] < colortempMax) {
								curColorValues[3] += 1;
								if (curColorValues[3] > colortempMax) {
									curColorValues[3] = colortempMax;
								}
							}
							bt_rOffset
									.setText(getFormatString(curColorValues[3]));
							mStructure.setValue(
									getSectionName(curSignalChannelIndex),
									COLOR_KEY_NAMES[curColorModeIndex],
									getStringFromValues(curColorValues));
							setTVColorTempOffset(curColorValues[3],
									curColorValues[4], curColorValues[5]);
							return true;
						default:
							return false;
						}
					}
					return false;
				}
			});

			bt_gOffset = (Button) findViewById(R.id.bt_gOffset);
			bt_gOffset.setNextFocusLeftId(bt_gOffset.getId());
			bt_gOffset.setNextFocusRightId(bt_gOffset.getId());
			bt_gOffset.setText(getFormatString(curColorValues[4]));
			bt_gOffset.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if (curColorValues[4] > colortempMin) {
								curColorValues[4] -= 1;
								if (curColorValues[4] < colortempMin) {
									curColorValues[4] = colortempMin;
								}
							}
							bt_gOffset
									.setText(getFormatString(curColorValues[4]));
							mStructure.setValue(
									getSectionName(curSignalChannelIndex),
									COLOR_KEY_NAMES[curColorModeIndex],
									getStringFromValues(curColorValues));
							setTVColorTempOffset(curColorValues[3],
									curColorValues[4], curColorValues[5]);
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if (curColorValues[4] < colortempMax) {
								curColorValues[4] += 1;
								if (curColorValues[4] > colortempMax) {
									curColorValues[4] = colortempMax;
								}
							}
							bt_gOffset
									.setText(getFormatString(curColorValues[4]));
							mStructure.setValue(
									getSectionName(curSignalChannelIndex),
									COLOR_KEY_NAMES[curColorModeIndex],
									getStringFromValues(curColorValues));
							setTVColorTempOffset(curColorValues[3],
									curColorValues[4], curColorValues[5]);
							return true;
						default:
							return false;
						}
					}
					return false;
				}
			});
			bt_bOffset = (Button) findViewById(R.id.bt_bOffset);
			bt_bOffset.setNextFocusLeftId(bt_bOffset.getId());
			bt_bOffset.setNextFocusRightId(bt_bOffset.getId());
			bt_bOffset.setText(getFormatString(curColorValues[5]));
			bt_bOffset.setOnKeyListener(new OnKeyListener() {

				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					// TODO Auto-generated method stub
					if (event.getAction() == KeyEvent.ACTION_DOWN) {
						switch (keyCode) {
						case KeyEvent.KEYCODE_DPAD_LEFT:
							if (curColorValues[5] > colortempMin) {
								curColorValues[5] -= 1;
								if (curColorValues[5] < colortempMin) {
									curColorValues[5] = colortempMin;
								}
							}
							bt_bOffset
									.setText(getFormatString(curColorValues[5]));
							mStructure.setValue(
									getSectionName(curSignalChannelIndex),
									COLOR_KEY_NAMES[curColorModeIndex],
									getStringFromValues(curColorValues));
							setTVColorTempOffset(curColorValues[3],
									curColorValues[4], curColorValues[5]);
							return true;
						case KeyEvent.KEYCODE_DPAD_RIGHT:
							if (curColorValues[5] < colortempMax) {
								curColorValues[5] += 1;
								if (curColorValues[5] > colortempMax) {
									curColorValues[5] = colortempMax;
								}
							}
							bt_bOffset
									.setText(getFormatString(curColorValues[5]));
							mStructure.setValue(
									getSectionName(curSignalChannelIndex),
									COLOR_KEY_NAMES[curColorModeIndex],
									getStringFromValues(curColorValues));
							setTVColorTempOffset(curColorValues[3],
									curColorValues[4], curColorValues[5]);
							return true;
						default:
							return false;
						}
					}
					return false;
				}
			});
			
//					
//			bt_backLight = (Button) findViewById(R.id.bt_backLight);
//			bt_backLight.setNextFocusLeftId(bt_backLight.getId());
//			bt_backLight.setNextFocusRightId(bt_backLight.getId());
//			bt_backLight.setText(getFormatString(curColorValues[6]));	
//			
//			bt_backLight.setOnKeyListener(new OnKeyListener() {
//				
//				@Override
//				public boolean onKey(View v, int keyCode, KeyEvent event) {
//					// TODO Auto-generated method stub
//					
//					if (event.getAction() == KeyEvent.ACTION_DOWN) {
//						switch (keyCode) {
//						case KeyEvent.KEYCODE_DPAD_LEFT:
//							if (curColorValues[6] > 0) {
//								curColorValues[6] -= 1;
//								if (curColorValues[6] < 0) {
//									curColorValues[6] = 0;
//								}
//							}
//							bt_backLight.setText(getFormatString(curColorValues[6]));
//							mStructure.setValue(
//									getSectionName(curSignalChannelIndex),
//									COLOR_KEY_NAMES[curColorModeIndex],
//									getStringFromValues(curColorValues));
//							setTVColorTempBackLight(curColorValues[6]);
//							return true;
//						case KeyEvent.KEYCODE_DPAD_RIGHT:
//							if (curColorValues[6] < 100) {
//								curColorValues[6] += 1;
//								if (curColorValues[6] > 100) {
//									curColorValues[6] = 100;
//								}
//							}
//							bt_backLight
//									.setText(getFormatString(curColorValues[6]));
//							mStructure.setValue(
//									getSectionName(curSignalChannelIndex),
//									COLOR_KEY_NAMES[curColorModeIndex],
//									getStringFromValues(curColorValues));
//							setTVColorTempBackLight(curColorValues[6]);
//							return true;
//						default:
//							return false;
//						}
//					}										
//					return false;
//				}
//			});
//
//			bt_save = (Button) findViewById(R.id.bt_save);
//			bt_save.setOnClickListener(new OnClickListener() {
//
//				@Override
//				public void onClick(View v) {
//					// TODO Auto-generated method stub
//					saveAndExport();
//				}
//			});

			bt_exit = (Button) findViewById(R.id.bt_exit);
			bt_exit.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					showMainWindow(mLayout_color);
				}
			});
			bt_save = (Button) findViewById(R.id.bt_save);
//			bt_save.setText(getString(R.string.save_to_all));
			bt_save.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View arg0) {
					// TODO Auto-generated method stub
//					new Handler().postDelayed(new Runnable() {
//						
//						@Override
//						public void run() {
//							// TODO Auto-generated method stub
//							for (int i = 0; i < 4; i++) {//type
//								for (int j = 0; j <= 7; j++) {//source
//									mStructure.setValue(getSectionName(j), COLOR_KEY_NAMES[i],
//											getStringFromValues(getCurrentColorValues(curSignalChannelIndex, i)));
//								}
//							}
//							Toast.makeText(mContext, getString(R.string.save_to_all)+" "+getString(R.string.pq_success), Toast.LENGTH_SHORT).show();
//						}
//					}, 2000);
					exportcolortemp();
				}
			});
		}		
		
		private void showAlertDialog1(String type) {
			 View view = LayoutInflater.from(mContext).inflate(R.layout.dialogselect, null);
			 RadioGroup rg_select= (RadioGroup) view.findViewById(R.id.rg_dialogselect);
			 if(type.equals("source")) {
				 for(int i=0;i<SourceName.length;i++){
				        RadioButton radioButton=new RadioButton(mContext);
				        radioButton.setId(i);
				        radioButton.setText(SourceName[i]);
				        radioButton.setTextColor(getResources().getColor(R.color.black));
				        rg_select.addView(radioButton);
				        
				    }
					rg_select.check(curSignalChannelIndex);

				    rg_select.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
				        @Override
				        public void onCheckedChanged(RadioGroup group, int checkedId) {
				        	Toast.makeText(mContext, "选择的是: " + checkedId, Toast.LENGTH_LONG).show();
							curSignalChannelIndex = checkedId;
							setTVSignalChannel(curSignalChannelIndex);
							curColorValues = getCurrentColorValues(
									curSignalChannelIndex, curColorModeIndex);
							refreshColorUI(curColorValues);
//							setTVColor(curColorValues);
				        }
				    });
			 }else if(type.equals("colormode")){
				 String[] list1=getResources().getStringArray(R.array.pq_color_mode);
				 for(int i=0;i<list1.length;i++){
				        RadioButton radioButton=new RadioButton(mContext);
				        radioButton.setId(i);
				        radioButton.setText(list1[i]);
				        radioButton.setTextColor(getResources().getColor(R.color.black));
				        rg_select.addView(radioButton);
				        
				    }
					rg_select.check(curColorModeIndex);

				    rg_select.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
				        @Override
				        public void onCheckedChanged(RadioGroup group, int checkedId) {
				        	Toast.makeText(mContext, "选择的是: " + checkedId, Toast.LENGTH_LONG).show();
							curColorModeIndex = checkedId;
							setTVContextualModel(curColorModeIndex);
							curColorValues = getCurrentColorValues(
									curSignalChannelIndex, curColorModeIndex);
							refreshColorUI(curColorValues);
//							setTVColor(curColorValues);
				        }
				    });
			 }
			    


//			 new AlertDialog.Builder(mContext)
//			   .setTitle("please select")
//			   .setView(view)
//			   .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
//			    @Override
//			    public void onClick(DialogInterface dialog, int which) {
//			     dialog.dismiss();
//			    }
//			   })
//			   .show();
			 AlertDialog.Builder myDialogBox = new AlertDialog.Builder(mContext);
	            myDialogBox.setTitle("please select");
	            myDialogBox.setView(view);
	            myDialogBox.setCancelable(false);
//	            myDialogBox.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
//				    @Override
//				    public void onClick(DialogInterface dialog, int which) {
//				     dialog.dismiss();
//				    }
//				   });
	            AlertDialog alertDialog = myDialogBox.create();
	            alertDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
	            	 
	    			@Override
	    			public boolean onKey(DialogInterface dialog, int keyCode,
	    					KeyEvent event) {
	    				if (keyCode == KeyEvent.KEYCODE_BACK) {
	    					dialog.dismiss();
	    				}
	    				return false;
	    			}
	    		});

//	            Window window = alertDialog.getWindow();
	            WindowManager.LayoutParams params =  alertDialog.getWindow().getAttributes();
	            params.width = 250;//WindowManager.LayoutParams.WRAP_CONTENT;
				params.height = WindowManager.LayoutParams.WRAP_CONTENT;
				params.gravity = Gravity.CENTER;
				alertDialog.getWindow().setAttributes(params);
				alertDialog.getWindow().setBackgroundDrawable(getResources().getDrawable(R.drawable.color_brown));
//				alertDialog.getWindow().setBackgroundDrawableResource(getResources().getColor(R.color.white));
				alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
	            alertDialog.show();
		}

		
		protected void setTVColorMode(int colorModeIndex) {
			// TODO Auto-generated method stub
			try {	
				MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_TEMP , colorModeIndex);
//				mTvMiscManager.setColorTempture(getENUMColorTempMode(colorModeIndex));
//				TVManager
//						.getInstance(NewPQService.this)
//						.getPictureManager()
//						.setColorTemperature(
//								getENUMColorTempMode(colorModeIndex));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				showMessage("error", "Failed to set scene mode", true);
				e.printStackTrace();
			}
		}

		private int getENUMColorTempMode(int colorModeIndex) {
			// TODO Auto-generated method stub
			int tempPicMode = MtkTvConfigTypeBase.VID_CLR_TEMP_USER;//CHENUMColorTempMode.CH_COLOR_TEMP_STANDARD;
			switch (colorModeIndex) {
			case 0:
//				ColorTempMode = CHENUMColorTempMode.CH_COLOR_TEMP_STANDARD;
				tempPicMode = MtkTvConfigTypeBase.VID_CLR_TEMP_WARM;
				break;
			case 1:
				tempPicMode = MtkTvConfigTypeBase.VID_CLR_TEMP_STANDARD;;
				break;
			case 2:
				tempPicMode = MtkTvConfigTypeBase.VID_CLR_TEMP_COOL;
				break;
			case 3:
				tempPicMode = MtkTvConfigTypeBase.VID_CLR_TEMP_USER;;
				break;
//			case 4:
//				ColorTempMode = ENUMColorTempMode.CH_COLOR_TEMP_MV;
//				break;
//			case 5:
//				ColorTempMode = ENUMColorTempMode.CH_COLOR_TEMP_SPORTS;
//				break;
//			case 6:
//				ColorTempMode = ENUMColorTempMode.CH_COLOR_TEMP_GAME;
//				break;				
			default:
//				ColorTempMode = CHENUMColorTempMode.CH_COLOR_TEMP_STANDARD;
				break;
			}
			return tempPicMode;
		}

		protected void setTVColor(int[] values) {
			// TODO Auto-generated method stub
			setTVColorTempGain(values[0], values[1], values[2]);
			setTVColorTempOffset(values[3], values[4], values[5]);
		}

		protected void refreshColorUI(int[] values) {
			// TODO Auto-generated method stub
			rg_signalChannels_color.setText(SourceName[curSignalChannelIndex]+"▶");
			String[] list1=getResources().getStringArray(R.array.pq_color_mode);
			rg_colorMode.setText(list1[curColorModeIndex]+"▶");
			bt_rGain.setText(getFormatString(values[0]));
			bt_gGain.setText(getFormatString(values[1]));
			bt_bGain.setText(getFormatString(values[2]));
			bt_rOffset.setText(getFormatString(values[3]));
			bt_gOffset.setText(getFormatString(values[4]));
			bt_bOffset.setText(getFormatString(values[5]));
			//bt_backLight.setText(getFormatString(values[6]));
		}

		protected boolean setTVSignalChannel(int signalChannelIndex) {
			// TODO Auto-generated method stub
//			try {
//				Intent tmp = new Intent(Intent.ACTION_VIEW);
////				tmp.addCategory("")
//				tmp.setClassName("com.mediatek.wwtv.tvcenter", "com.mediatek.wwtv.tvcenter.nav.TurnkeyUiMainActivity");
//				tmp.setData(Uri.parse(sourceMap.get(SourceName[signalChannelIndex])));
//				tmp.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//				startActivity(tmp);
////				MtkTvInputSource.getInstance().changeInputSourcebySourceid(MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_TV);
////				mTvMiscManager.startInputSource(0,getEnumInputSourceFromIndex(signalChannelIndex).ordinal(), -1);
////				TVManager
////						.getInstance(NewPQService.this)
////						.getSourceManager()
////						.selectInputSource(
////								getEnumInputSourceFromIndex(signalChannelIndex));
//
//				if (signalChannelIndex == 0) {
////					int channelNum = mTvChannelManager.getCurrentChannelNumber();
////					mTvChannelManager.setAtvChannel(channelNum);
//					
////					int channelNum = TVManager.getInstance(NewPQService.this)
////							.getATVChannelManager().getCurChannelNum();
////					TVManager.getInstance(NewPQService.this).getATVPlayer()
////							.play(channelNum);
//
//				}
//				enableColorViews(true);
//			} catch (Exception e) {
//				e.printStackTrace();
//				Log.v("TVtool","The switched signal channel failed. Please switch manually");	
//				showMessage("Color temperature锛?","The switched signal channel failed. Please switch manually",true);
//				//enableColorViews(false);
//			}
//			


			if(signalChannelIndex == 0)//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_RESERVED)
			{
				showMessage("Be careful", "This tool is temporarily unable to cut or cut the signal channel into USB锛孭lease make sure that the USB channel is currently in use, otherwise manually switch", true);
			}

			else
			{

			
				try {
					enableColorViews(true);

					Intent tmp = new Intent(Intent.ACTION_VIEW);
					tmp.setAction("com.mediatek.select.source");
					tmp.putExtra("com.mediatek.select.sourcename", SourceName[signalChannelIndex]);
					sendBroadcast(tmp);

				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
						showMessage("colormode","the switched signal channel failed. Please switch manually",true);
					//enableViews(false);
					return false;
				}
			}
			return true;
		
		}

		private void enableColorViews(boolean enabled) {
			// TODO Auto-generated method stub
			rg_colorMode.setEnabled(enabled);
			rg_colorMode.setFocusable(enabled);

			bt_rGain.setEnabled(enabled);
			bt_rGain.setFocusable(enabled);

			bt_gGain.setEnabled(enabled);
			bt_gGain.setFocusable(enabled);

			bt_bGain.setEnabled(enabled);
			bt_bGain.setFocusable(enabled);

			bt_rOffset.setEnabled(enabled);
			bt_rOffset.setFocusable(enabled);

			bt_gOffset.setEnabled(enabled);
			bt_gOffset.setFocusable(enabled);

			bt_bOffset.setEnabled(enabled);
			bt_bOffset.setFocusable(enabled);
		}

		protected int getEnumInputSourceFromIndex(int idx) {
			// TODO Auto-generated method stub
			int tempSource = 0;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_TV;//EnumInputSource.E_INPUT_SOURCE_ATV;
			switch (idx) {
			case StaticValues.CHTV_SRC_ATV:
				tempSource = 0;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_TV;//EnumInputSource.E_INPUT_SOURCE_ATV;
				break;
			case StaticValues.CHTV_SRC_DTV:
				tempSource = 0;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_TV;//EnumInputSource.E_INPUT_SOURCE_DTV;
				break;				
			case StaticValues.CHTV_SRC_AV:
				tempSource = 1;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_COMPOSITE;//EnumInputSource.E_INPUT_SOURCE_CVBS;
				break;
			case StaticValues.CHTV_SRC_YPBPR:
				tempSource = 4;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_COMPONENT;//EnumInputSource.E_INPUT_SOURCE_YPBPR;
				break;
			case StaticValues.CHTV_SRC_HDMI:
				tempSource = 5;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_HDMI;//EnumInputSource.E_INPUT_SOURCE_HDMI2;
				break;
			case StaticValues.CHTV_SRC_VGA:
				tempSource = 6;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_VGA;
				break;				
			case StaticValues.CHTV_SRC_MMP:
				tempSource = 7;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_RESERVED;//EnumInputSource.E_INPUT_SOURCE_STORAGE;				
			case StaticValues.CHTV_SRC_NET:
				tempSource = 7;//MtkTvInputSourceBase.InputSourceRecord.INPS_TYPE_NUMERICAL_RESERVED;//EnumInputSource.E_INPUT_SOURCE_STORAGE;//@wql
				break;
			default:
				break;

			}
			return tempSource;
		}

		protected void setTVColorTempOffset(int roffset, int goffset,
				int boffset) {
			// TODO Auto-generated method stub
			try {
				mcolortempdata = new ColorTempData(curColorValues[0], curColorValues[1], curColorValues[2], roffset, goffset, boffset);
				MtkTvFApiDisplay.getInstance().setWbGainOffsetEx(EnumColorTemperature.values()[clortempindex], mcolortempdata, inputSrcType);
				MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_OFFSET_R , roffset);
				MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_OFFSET_G , goffset);
				MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_OFFSET_B , boffset);
//				mTvMiscManager.setColorTempOffset(roffset, goffset, boffset);
//				TVManager.getInstance(NewPQService.this).getMiscManager()
//						.setColorTempOffset(roffset, goffset, boffset);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				showMessage("error", "failed to set color temperature offset", true);
			}
		}
		
		protected void setTVColorTempBackLight(int backlight){
			// tvos interface 
			try {
				MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_DISP_DISP_DISP_BACK_LIGHT , backlight);
//				mTvMiscManager.setBackLight(backlight);
//				TVManager.getInstance(mContext)
//						.getPictureManager().setFactoryBacklight(backlight);	
				
				Log.i(TAG, "setFactoryBacklight : " + backlight);
			} catch (Exception e){
				e.printStackTrace();
				showMessage("error", "failed to set backlight", true);				
			}
			
		}

		protected void setTVColorTempGain(int rgain, int ggain, int bgain) {
			// TODO Auto-generated method stub
			try {
				mcolortempdata = new ColorTempData(rgain, ggain, bgain, curColorValues[3], curColorValues[4], curColorValues[5]);
				MtkTvFApiDisplay.getInstance().setWbGainOffsetEx(EnumColorTemperature.values()[clortempindex], mcolortempdata, inputSrcType);
				MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_GAIN_R , rgain);
				MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_GAIN_G , ggain);
				MtkTvConfig.getInstance().setConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_GAIN_B , bgain);
//				mTvMiscManager.setColorTempGain(rgain, ggain, bgain);
//				TVManager.getInstance(NewPQService.this).getMiscManager()
//						.setColorTempGain(rgain, ggain, bgain);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				showMessage("error", "failed to set color temperature Gain", true);
			}
		}

		protected String getStringFromValues(int[] values) {
			// TODO Auto-generated method stub
			String retStr = "{";
			for (int i = 0; i < values.length; i++) {
				retStr += String.valueOf(values[i]);
				if (i < values.length - 1) {
					retStr += ",";
				}
			}
			retStr += "}";
			return retStr;
		}

		private String getFormatString(int value) {
			// TODO Auto-generated method stub
			String retStr = "";
			retStr += value;
			if (value < 10) {
				retStr += "   ";
			} else if (value < 100) {
				retStr += "  ";
			} else {

			}
			return "◀ " + retStr + " ▶";
		}

		private int[] getCurrentColorValues(int signalChannelIdx,
				int colorModeIdx) {
			// TODO Auto-generated method stub
//			String valuesStr = mStructure.getValue(
//					getSectionName(signalChannelIdx),
//					COLOR_KEY_NAMES[colorModeIdx]);
//
//			return getValuesFromString(valuesStr);
			int[] values = {0,0,0,0,0,0};
			inputSrcType = MtkTvFApiInputSource.getInstance().getCurrentInputSourceType();
			clortempindex = MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_TEMP);
			Toast.makeText(mContext, "current source=" + inputSrcType+"  clortempindex="+clortempindex, Toast.LENGTH_LONG).show();
			mcolortempdata = MtkTvFApiDisplay.getInstance().getWbGainOffsetEx(EnumColorTemperature.values()[clortempindex], inputSrcType);
			values[0] = mcolortempdata.redGain;//MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_GAIN_R);
			values[1] = mcolortempdata.greenGain;//MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_GAIN_G);
			values[2] = mcolortempdata.blueGain;//MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_GAIN_B);
			values[3] = mcolortempdata.redOffset;//MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_OFFSET_R);
			values[4] = mcolortempdata.greenOffset;//.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_OFFSET_G);
			values[5] = mcolortempdata.blueOffset;//MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_OFFSET_B);
			return values;
		}

		private int[] getValuesFromString(String valuesStr) {
			// TODO Auto-generated method stub
			int[] retValues = { 0, 0, 0, 0, 0, 0 };
			//int[] retValues = { 0, 0, 0, 0, 0, 0, 0 };
			try {
				String[] values = valuesStr.trim().replace("{", "")
						.replace("}", "").split(",");
				for (int i = 0; i < retValues.length; i++) {
					retValues[i] = Integer.valueOf(values[i]);
				}
			} catch (Exception e) {
				e.printStackTrace();

				showMessage("error", "the data format is wrong. Please provide an active configuration file and rerun the program", true);
			}
			return retValues;
		}

		private String getSectionName(int signalChannelIdx) {
			// TODO Auto-generated method stub
			switch (signalChannelIdx) {
			case 0:
				return "CHTV_PIC_COLOR_TEMP_ATV";
			case 1:
				return "CHTV_PIC_COLOR_TEMP_DTV";
			case 2:
				return "CHTV_PIC_COLOR_TEMP_AV";
			case 3:
				return "CHTV_PIC_COLOR_TEMP_YPBPR";
			case 4:
				return "CHTV_PIC_COLOR_TEMP_HDMI";
			case 5:
				return "CHTV_PIC_COLOR_TEMP_VGA";
			case 6:
				return "CHTV_PIC_COLOR_TEMP_MMP";								
			case 7:
				return "CHTV_PIC_COLOR_TEMP_NET";
			default:
				break;
			}
			return null;
		}		
		
		private int getCurrentColorModeIndex() {
			// TODO Auto-generated method stub
			int colorTempModeID = 0;
			int currentColorTempMode = MtkTvConfig.getInstance().getConfigValue(MtkTvConfigTypeBase.CFG_VIDEO_CLR_TEMP);
//			CHENUMColorTempMode currentColorTempMode = CHENUMColorTempMode.CH_COLOR_TEMP_STANDARD;
			try {
//				currentColorTempMode = TVManager
//						.getInstance(mContext)
//						.getPictureManager().getColorTemperature();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				showMessage("error", "Failed to get color temperature mode", true);
			}
			switch (currentColorTempMode) {
			case MtkTvConfigTypeBase.VID_CLR_TEMP_WARM:
				colorTempModeID = 0;
				break;
			case MtkTvConfigTypeBase.VID_CLR_TEMP_STANDARD:
				colorTempModeID = 1;
				break;
			case MtkTvConfigTypeBase.VID_CLR_TEMP_COOL:
				colorTempModeID = 2;
				break;
			case MtkTvConfigTypeBase.VID_CLR_TEMP_USER:
				colorTempModeID = 3;
				break;
			default:
				break;
			}
			return colorTempModeID;

		}

		@Override
		public boolean dispatchKeyEvent(KeyEvent event) {
			// TODO Auto-generated method stub			
			if(event.getKeyCode() == KeyEvent.KEYCODE_BACK)
			{
				if(event.getAction() == KeyEvent.ACTION_DOWN)
				{
					showMainWindow(mLayout_color);
				}
				return true;
			}
			
			return super.dispatchKeyEvent(event);
		}
	}


	private class MySpinnerAdapter extends ArrayAdapter<String> {
		Context context;
		String[] items = new String[] {};
		int textViewId;
		int layoutId;
		boolean bLayout = false;

		public MySpinnerAdapter(final Context context,
				final int textViewResourceId, final String[] objects) {
			super(context, textViewResourceId, objects);
			Log.i(TAG, "lhtest 0");
			this.context = context;
			textViewId = textViewResourceId;
			items = objects;
			int size = 0;
			for(String str:items){
				 Log.i(TAG,"lhprint:"+str); 
				 size++;
		  	}
		}

		public MySpinnerAdapter(Context context, int resource,
				int textViewResourceId, String[] objects) {
			super(context, resource, textViewResourceId, objects);
			// TODO Auto-generated constructor stub
			Log.i(TAG, "lhtest 00");
			this.context = context;
			layoutId = resource;
			bLayout = true;
			textViewId = textViewResourceId;
			items = objects;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			if (bLayout) {
				Log.i(TAG, "lhtest 000");
				if (convertView == null) {
					convertView = mInflater.inflate(layoutId, parent, false);
				}
				TextView tv = (TextView) convertView.findViewById(textViewId);
				tv.setText(items[position]);
//				tv.setTextSize(14);
			} else {
				Log.i(TAG, "lhtest 0000");
				if (convertView == null) {
					convertView = mInflater.inflate(textViewId, parent, false);
				}
				TextView tv = (TextView) convertView;
				tv.setText(items[position]);
//				tv.setTextSize(14);

			}
			if (convertView == null) {
				Log.i(TAG, "lhtest error1");
			}
			return convertView;
		}

		@Override
		public View getDropDownView(int position, View convertView,
				ViewGroup parent) {
			// TODO Auto-generated method stub
			
			if (bLayout) {
				Log.i(TAG, "lhtest 00000");
				if (convertView == null) {
					convertView = mInflater.inflate(layoutId, parent, false);
				}
				TextView tv = (TextView) convertView.findViewById(textViewId);
				tv.setText(items[position]);
//				tv.setTextSize(10);
			} else {
				Log.i(TAG, "lhtest 000000");
				if (convertView == null) {
					convertView = mInflater.inflate(textViewId, parent, false);
				}
				TextView tv = (TextView) convertView;
				tv.setText(items[position]);
//				tv.setTextSize(10);

			}
			if (convertView == null) {
				Log.i(TAG, "lhtest error2");
			}
			return convertView;
		}

	}

	public void exitPQ() {
		// TODO Auto-generated method stub
		mWindowManager.removeView(mLayout_main);
		Intent TVtoolServiceIntent = new Intent(this, TvToolService.class);
		startService(TVtoolServiceIntent);
		finish();
	}

	public boolean CheckSDCardSwitchOn() {
		// TODO Auto-generated method stub
//		
//        if (deviceLabel.size() ==1){
//        	Log.i(TAG, "U disk was not found");
//        	return false;
//        }else{
//        	Log.i(TAG, "U disk was found");
//        	SDPath = deviceLabel.get(1).mMountPoint;
//        	Log.i(TAG, "SDPath = " + SDPath);
//	        for (int i = 0; i < deviceLabel.size(); i++) {
//	  		    Log.i(TAG, "mMountPoint: " + deviceLabel.get(i).mMountPoint);
//	  		}        	
//        	return true;
//        }    
		//SDPath
//		if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
//		{
//		   return true;
//   	  	}
//		else
//		{
//		  return false;
//		}
//		
	try {
			StorageManager mStorageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
			Class<?>[] paramClasses = {};
			Object[] params = {};
			Method getVolumePathsMethod = StorageManager.class.getMethod("getVolumePaths", paramClasses);
			String[] paths = (String[]) getVolumePathsMethod.invoke(mStorageManager, params);		
			int size = 0;
			for(String str:paths){
				 Log.i(TAG,"myprint:"+str); 
				 size++;
		  	}
			
			if(size<=1){
				Log.i(TAG, "U disk was not found");
				return false;
			}else{
				SDPath = paths[1];
				Log.i(TAG, "U disk was found");
				Log.i(TAG, "SDPath = " + SDPath);
				return true;			
			     }			
			
		} catch (Exception e) {
		    Log.e(TAG, "CheckSDCardSwitchOn() failed", e);
		    return false;
		}

		
		
	}

	public void showMessage(String title, String msg, boolean bSingleButton) {
		// TODO Auto-generated method stub
		PQLayout_Message layout = new PQLayout_Message(mContext, bSingleButton)
				.setMessage(title, msg);
		if(bOnCreate)
		{
			messages.add(layout);
		}
		else
		{
			layout.show();
		}
		
	}

	class PQLayout_Message extends LinearLayout {
		TextView tv_title, tv_message;
		Button bt_ok, bt_cancel;
		WindowManager.LayoutParams params;

		public PQLayout_Message(Context context, boolean bSingleButton) {
			super(context);
			// TODO Auto-generated constructor stub
			mInflater.inflate(R.layout.pq_show_message, this);
			tv_title = (TextView) findViewById(R.id.tv_title);
			tv_message = (TextView) findViewById(R.id.tv_message);
			bt_ok = (Button) findViewById(R.id.bt_ok);
			bt_cancel = (Button) findViewById(R.id.bt_cancel);

			params = new WindowManager.LayoutParams();
			params.type = WindowManager.LayoutParams.TYPE_PHONE;
			params.format = PixelFormat.RGBA_8888;
			params.width = WindowManager.LayoutParams.WRAP_CONTENT;
			params.height = WindowManager.LayoutParams.WRAP_CONTENT;
			params.gravity = Gravity.CENTER;
			params.x = 0;
			params.y = 0;

			bt_ok.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					// TODO Auto-generated method stub
					hide();
				}
			});
			bt_cancel.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					// TODO Auto-generated method stub
					hide();
				}
			});

			if (bSingleButton) {
				bt_cancel.setVisibility(View.GONE);
			}
		}

		public PQLayout_Message setMessage(String title, String msg) {
			tv_title.setText(title);
			tv_message.setText(msg);
			return this;
		}

		public void show() {
			mWindowManager.addView(this, params);
			bt_ok.requestFocus();
		}

		public void hide() {
			mWindowManager.removeView(this);
		}

		public PQLayout_Message setOKListener(View.OnClickListener listener) {
			bt_ok.setOnClickListener(listener);
			return this;
		}

		public PQLayout_Message setCancelListener(View.OnClickListener listener) {
			bt_cancel.setOnClickListener(listener);
			return this;
		}

		@Override
		public boolean dispatchKeyEvent(KeyEvent event) {
			// TODO Auto-generated method stub

			if (event.getAction() == KeyEvent.ACTION_DOWN
					&& event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
				hide();
				return true;
			}
			return super.dispatchKeyEvent(event);
		}

	}

	/*
	 * private void updateFileNameAndPath(String mPanelModel) { // TODO
	 * Auto-generated method stub mPanelModel = mPanelModel; mFileName =
	 * getFileName(mPanelModel); mLocalPath = getLocalPath(mPanelModel); }
	 */

	String[] SECTION_NAMES = { 
	
	"IniVersion",

	"CHTV_PIC_CURVE_BRI",

	"CHTV_PIC_CURVE_CNT",

	"CHTV_PIC_CURVE_SAT",

	"CHTV_PIC_CURVE_SHP",

	"CHTV_PIC_CURVE_HUE",

	"CHTV_PIC_COLOR_TEMP_ATV",
	
	"CHTV_PIC_COLOR_TEMP_DTV",

	"CHTV_PIC_COLOR_TEMP_AV",

	"CHTV_PIC_COLOR_TEMP_YPBPR",

	"CHTV_PIC_COLOR_TEMP_HDMI",

	"CHTV_PIC_COLOR_TEMP_VGA",
	
	"CHTV_PIC_COLOR_TEMP_MMP",

	"CHTV_PIC_COLOR_TEMP_NET",

	//"CHTV_PIC_GAMMA_TABLE_10000K_11500K",
	"CHTV_PIC_GAMMA_TABLE_STANDARD",

	"CHTV_PIC_GAMMA_TABLE_SHOP",

	"CHTV_PIC_GAMMA_TABLE_UMAX",

	"CHTV_PIC_GAMMA_TABLE_HDR",
	
	"CHTV_PIC_GAMMA_TABLE_4",
	
	"CHTV_PIC_GAMMA_TABLE_5",
	
    "CHTV_PICTUREMODE_SETTING",
    
    "CHTV_PICTUREMODE_SETTING_SHOP",
	//"CHTV_PIC_GAMMA_TABLE_CHILD_MODE",

	//"CHTV_PIC_GAMMA_TABLE_SHOP_PHOTO", 
	//"CHTV_PIC_GAMMA_TABLE_8500K_10000K", //20
	
	//"CHTV_PIC_GAMMA_TABLE_11500K_13000K", //21
	
	};

	String[] SECTION_NAMES_BENQ = { 
			
			"IniVersion",

			"CHTV_PIC_CURVE_BRI",

			"CHTV_PIC_CURVE_CNT",

			"CHTV_PIC_CURVE_SAT",

			"CHTV_PIC_CURVE_SHP",

			"CHTV_PIC_CURVE_HUE",

			"CHTV_PIC_COLOR_TEMP_ATV",
			
			"CHTV_PIC_COLOR_TEMP_DTV",

			"CHTV_PIC_COLOR_TEMP_AV",

			"CHTV_PIC_COLOR_TEMP_YPBPR",

			"CHTV_PIC_COLOR_TEMP_HDMI",

			"CHTV_PIC_COLOR_TEMP_VGA",
			
			"CHTV_PIC_COLOR_TEMP_MMP",

			"CHTV_PIC_COLOR_TEMP_NET",

			//"CHTV_PIC_GAMMA_TABLE_10000K_11500K",
			"CHTV_PIC_GAMMA_TABLE_STANDARD",

			"CHTV_PIC_GAMMA_TABLE_SHOP",

			"CHTV_PIC_GAMMA_TABLE_UMAX",

			"CHTV_PIC_GAMMA_TABLE_HDR",
			
			"CHTV_PIC_GAMMA_TABLE_4",
			
			"CHTV_PIC_GAMMA_TABLE_5",
			
			"CHTV_LIGHTSENSOR_BENQ",
			
			"CHTV_PICTUREMODE_SETTING",
			
			"CHTV_PICTUREMODE_SETTING_SHOP",

			//"CHTV_PIC_GAMMA_TABLE_CHILD_MODE",

			//"CHTV_PIC_GAMMA_TABLE_SHOP_PHOTO", 
			//"CHTV_PIC_GAMMA_TABLE_8500K_10000K", //20
			
			//"CHTV_PIC_GAMMA_TABLE_11500K_13000K", //21
			
			};
	
	String[] INI_VERSION_KEY_NAMES = { 
			"PQID", 
			"Ver" 
			};

//	String[] LINEAR_KEY_NAMES = { "ATV", "DTV_SD", "DTV_HD", "AV_PAL",
//			"AV_NTSC", "YPBPR_SD", "YPBPR_HD", "HDMI_SD", "HDMI_HD", "HDMI_4K",
//			"DVI_ON", "DVI_OFF", "VGA_ON", "VGA_OFF", "USB_SD", "USB_HD","USB_4K",
//			"NET_SD", "NET_HD", "IPTV" };
//	String[] LINEAR_KEY_NAMES = { 
//			"ATV_PAL", //0
//			"ATV_NTSC",//1
//			"DTV_SD", //2
//			"DTV_HD",//3
//			"DTV_UD", //4
//			"AV_PAL",//5
//			"AV_NTSC", //6
//			"YPBPR_SD", //7
//			"YPBPR_HD", //8
//			"HDMI_SD", //9
//			"HDMI_HD", //10
//			"HDMI_UD",//11
//			"HDMI_VESA",//12
//			"HDMI_HDR",//13
//			"USB_SD",//14
//			"USB_HD", //15
//			"USB_UD", //16
//			"USB_HDR", //17
//			"NET_SD", //18
//			"NET_HD", //19
//			"NET_UD",//20
//			"NET_HDR",//21
//			"VGA", //22
//			"3D", //23
//			"UMAX_FHD",//24
//			"UMAX_UD", //25
//			"CHILD_FHD",//26
//			"CHILD_UD",//27
//			"RESERVED1",//28
//			"RESERVED2"//29
//			};//COUNT=30
	String[] LINEAR_KEY_NAMES = { 
			"ATV_PAL", //0
			"ATV_NTSC",//1
			"ATV_SECAM",//2
			"AV_PAL",	//3					
			"AV_NTSC", //4
			"AV_SECAM",//5
			"YPBPR_SD_I", //6
			"YPBPR_SD_P",//7
			"YPBPR_720P", //8
			"YPBPR_1080I50", //9
			"YPBPR_1080I60", //10
			"YPBPR_1080P", //11
			"HDMI_SD_I", //12
			"HDMI_SD_P",//13
			"HDMI_720P",//14
			"HDMI_1080I50",//15
			"HDMI_1080I60",//16
			"HDMI_1080P", //17
			"HDMI_UD", //18
			"HDMI_VESA", //19
			"HDMI_HDR", //20
			"VGA", //21
			"DTV_SD",//22
			"DTV_HD",//23
			"DTV_UD", //24
			"MMP_SD", //25
			"MMP_HD",//26
			"MMP_UD", //27
			"MMP_HDR",//28
			"NET_SD",//29
			"NET_HD",//30
			"NET_UD",//31
			"NET_HDR",//32
			"3D",//33
			"UMAX_FHD",//34
			"UMAX_UD",//35
			"M_FHD",//36
			"M_UD",//37
			"RESERVED1",//38
			"RESERVED2",//39
			};//COUNT=40
//		
//	String[] COLOR_KEY_NAMES = { 
//	"STANDARD", 
//	"MOVIE", 
//	"UMAX", 
//	"READING", 
//	"MV", 
//	"SPORTS", 
//	"GAME" 
//	};

	String[] COLOR_KEY_NAMES = { 
			"WARM", 
			"STD", 
			"COOL", 
			"USER", 	
			};
	String[] GAMMA_KEY_NAMES = { 
	"R_TABLE", 
	"G_TABLE", 
	"B_TABLE" 
	};
	
	String[] PICTUREMODE_SETTING_KEYNAMES = { 
			"STANDARD", 
			"VIVID", 
			"HOME",
			"MILD",
			"USER"
			};
	
	String[] PICTUREMODE_SETTING_SHOP_KEYNAMES = { 
			"STANDARD", 
			"VIVID", 
			"HOME",
			"MILD",
			"USER"
			};
	String[] LIGHT_SENSOR_KEY_NAMES = { 
			"LIGHTSENSOR_LINEAR" 
			};

	String[] getKeyNames(String sectionName) {
		for (int i = 0; i < SECTION_NAMES.length; i++) {
			if (sectionName.equals(SECTION_NAMES[i])) {
				if (0 == i) {
					return INI_VERSION_KEY_NAMES;
				} else if (i < 6) {
					return LINEAR_KEY_NAMES;
				} else if (i < 14) {
					return COLOR_KEY_NAMES;
				} else if (i < 20) {
					return GAMMA_KEY_NAMES;
				} else if(i < 21){
					return PICTUREMODE_SETTING_KEYNAMES;
				} else if(i < 22){
					return PICTUREMODE_SETTING_SHOP_KEYNAMES;
				}
			}
		}
		return null;
	}
	
	String[] getKeyNamesBenq(String sectionName) {
		for (int i = 0; i < SECTION_NAMES_BENQ.length; i++) {
			if (sectionName.equals(SECTION_NAMES_BENQ[i])) {
				if (0 == i) {
					return INI_VERSION_KEY_NAMES;
				} else if (i < 6) {
					return LINEAR_KEY_NAMES;
				} else if (i < 14) {
					return COLOR_KEY_NAMES;
				} else if (i < 20) {
					return GAMMA_KEY_NAMES;
				} else if(i < 21){
					return LIGHT_SENSOR_KEY_NAMES;
				} else if(i < 22){
					return PICTUREMODE_SETTING_KEYNAMES;
				} else if(i < 23){
					return PICTUREMODE_SETTING_SHOP_KEYNAMES;
				}
			}
		}
		return null;
	}

	private void setDefaultValues() {
		// TODO Auto-generated method stub
		mStructure.setValue("IniVersion", "PQID", "CHPQ");
		mStructure.setValue("IniVersion", "Ver", "1.00");
		
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[0],"{29,77,127,152,178}");		
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[1],"{29,77,127,152,178}");	
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[2],"{29,77,126,144,162}");	
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[3],"{29,77,126,144,162}");		
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[4],"{29,77,126,144,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[5],"{29,77,127,144,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[6],"{29,77,127,144,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[7],"{29,77,127,144,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[8],"{29,78,127,144,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[9],"{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[10],"{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[11],"{32,79,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[12],"{32,79,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[13],"{32,79,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[14],"{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[15],"{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[16],"{39,85,126,144,160}");		
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[17],"{39,85,126,144,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[18],"{40,83,127,144,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[19], "{41,83,126,144,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[20], "{40,83,127,144,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[21], "{41,83,126,144,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[22], "{40,85,130,146,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[23], "{40,85,130,146,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[24], "{40,85,130,146,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[25], "{40,85,130,146,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[26], "{40,85,130,146,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[27], "{40,85,130,146,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[28], "{40,85,130,146,162}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[29], "{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[30], "{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[31], "{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[32], "{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[33], "{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[34], "{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[35], "{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[36], "{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[37], "{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[38], "{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_BRI", LINEAR_KEY_NAMES[39], "{30,78,126,143,160}");
		
		
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[0], "{42,84,127,141,156}");		
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[1],"{42,84,127,141,156}");	
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[2],"{42,84,126,142,158}");	
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[3],"{42,84,126,141,156}");		
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[4],"{42,84,126,141,156}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[5],"{42,84,126,141,156}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[6],"{42,84,126,141,156}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[7],"{42,84,126,141,156}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[8],"{42,84,126,141,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[9],"{40,83,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[10],"{39,82,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[11],"{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[12],"{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[13],"{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[14],"{40,83,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[15],"{30,78,126,143,160}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[16],"{42,84,126,142,158}");		
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[17],"{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[18],"{40,83,126,141,156}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[19], "{40,83,126,141,156}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[20], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[21], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[22], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[23], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[24], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[25], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[26], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[27], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[28], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[29], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[30], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[31], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[32], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[33], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[34], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[35], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[36], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[37], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[38], "{42,84,126,142,158}");
		mStructure.setValue("CHTV_PIC_CURVE_CNT", LINEAR_KEY_NAMES[39], "{42,84,126,142,158}");
		
		
		mStructure.setValue("CHTV_PIC_CURVE_SAT",LINEAR_KEY_NAMES[0], "{0,37,74,115,156}");		
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[1],"{0,37,74,115,156}");	
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[2],"{0,37,74,115,156}");	
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[3],"{0,37,74,115,156}");		
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[4],"{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[5],"{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[6],"{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[7],"{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[8],"{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[9],"{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[10],"{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[11],"{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[12],"{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[13],"{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[14],"{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[15],"{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[16],"{0,37,74,115,156}");		
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[17],"{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[18],"{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[19], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[20], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[21], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[22], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[23], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[24], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[25], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[26], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[27], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[28], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[29], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[30], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[31], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[32], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[33], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[34], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[35], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[36], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[37], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[38], "{0,37,74,115,156}");
		mStructure.setValue("CHTV_PIC_CURVE_SAT", LINEAR_KEY_NAMES[39], "{0,37,74,115,156}");
		
		
		
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[0], "{0,31,62,79,96}");		
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[1],"{0,31,62,79,96}");	
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[2],"{0,31,62,79,96}");	
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[3],"{0,31,62,79,96}");		
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[4],"{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[5],"{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[6],"{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[7],"{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[8],"{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[9],"{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[10],"{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[11],"{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[12],"{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[13],"{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[14],"{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[15],"{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[16],"{0,31,62,79,96}");		
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[17],"{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[18],"{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[19], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[20], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[21], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[22], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[23], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[24], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[25], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[26], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[27], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[28], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[29], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[30], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[31], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[32], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[33], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[34], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[35], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[36], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[37], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[38], "{0,31,62,79,96}");
		mStructure.setValue("CHTV_PIC_CURVE_SHP", LINEAR_KEY_NAMES[39], "{0,31,62,79,96}");
		
		
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[0], "{48,96,128,160,192}");		
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[1],"{48,96,128,160,192}");	
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[2],"{48,96,128,160,192}");	
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[3],"{48,96,128,160,192}");		
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[4],"{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[5],"{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[6],"{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[7],"{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[8],"{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[9],"{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[10],"{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[11],"{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[12],"{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[13],"{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[14],"{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[15],"{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[16],"{48,96,128,160,192}");		
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[17],"{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[18],"{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[19], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[20], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[21], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[22], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[23], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[24], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[25], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[26], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[27], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[28], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[29], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[30], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[31], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[32], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[33], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[34], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[35], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[36], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[37], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[38], "{48,96,128,160,192}");
		mStructure.setValue("CHTV_PIC_CURVE_HUE", LINEAR_KEY_NAMES[39], "{48,96,128,160,192}");
				

		
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_ATV", "WARM","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_ATV", "STD","{50,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_ATV", "COOL","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_ATV", "USER","{50,50,50,50,50,50}");		
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_ATV", "MV","{50,50,50,50,50,50,100}");			
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_ATV", "SPORTS","{50,50,60,50,50,50,100}");	
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_ATV", "GAME","{50,50,60,50,50,50,100}");
//	    mStructure.setValue("CHTV_PIC_COLOR_TEMP_ATV", "FOOTBALL","{50,50,50,50,50,50,100}");
		
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_DTV", "WARM","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_DTV", "STD","{50,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_DTV", "COOL","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_DTV", "USER","{50,50,50,50,50,50}");	
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_DTV", "MV","{50,50,50,50,50,50,100}");			
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_DTV", "SPORTS","{50,50,60,50,50,50,100}");	
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_DTV", "GAME","{50,50,60,50,50,50,100}");	
	//	mStructure.setValue("CHTV_PIC_COLOR_TEMP_DTV", "FOOTBALL","{50,50,50,50,50,50,100}");	
		
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_AV", "WARM","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_AV", "STD","{50,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_AV", "COOL","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_AV", "USER","{50,50,50,50,50,50}");		
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_AV", "MV","{50,50,50,50,50,50,100}");			
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_AV", "SPORTS","{50,50,60,50,50,50,100}");	
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_AV", "GAME","{50,50,60,50,50,50,100}");
	//	mStructure.setValue("CHTV_PIC_COLOR_TEMP_AV", "FOOTBALL","{50,50,50,50,50,50,100}");	

		
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_YPBPR", "WARM","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_YPBPR", "STD","{50,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_YPBPR", "COOL","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_YPBPR", "USER","{50,50,50,50,50,50}");		
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_YPBPR", "MV","{50,50,50,50,50,50,100}");			
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_YPBPR", "SPORTS","{50,50,60,50,50,50,100}");	
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_YPBPR", "GAME","{50,50,60,50,50,50,100}");	
	//	mStructure.setValue("CHTV_PIC_COLOR_TEMP_YPBPR", "FOOTBALL","{50,50,50,50,50,50,100}");	

		
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_HDMI", "WARM","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_HDMI", "STD","{50,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_HDMI", "COOL","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_HDMI", "USER","{50,50,50,50,50,50}");		
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_HDMI", "MV","{50,50,50,50,50,50,100}");			
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_HDMI", "SPORTS","{50,50,60,50,50,50,100}");	
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_HDMI", "GAME","{50,50,60,50,50,50,100}");
	//	mStructure.setValue("CHTV_PIC_COLOR_TEMP_HDMI", "FOOTBALL","{50,50,50,50,50,50,100}");


		
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_VGA", "WARM","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_VGA", "STD","{50,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_VGA", "COOL","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_VGA", "USER","{50,50,50,50,50,50}");		
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_VGA", "MV","{50,50,50,50,50,50,100}");			
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_VGA", "SPORTS","{50,50,60,50,50,50,100}");	
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_VGA", "GAME","{50,50,60,50,50,50,100}");	
	//	mStructure.setValue("CHTV_PIC_COLOR_TEMP_VGA", "FOOTBALL","{50,50,50,50,50,50,100}");


		mStructure.setValue("CHTV_PIC_COLOR_TEMP_MMP", "WARM","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_MMP", "STD","{50,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_MMP", "COOL","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_MMP", "USER","{50,50,50,50,50,50}");		
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_MMP", "MV","{50,50,50,50,50,50,100}");			
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_MMP", "SPORTS","{50,50,60,50,50,50,100}");	
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_MMP", "GAME","{50,50,60,50,50,50,100}");	
	//	mStructure.setValue("CHTV_PIC_COLOR_TEMP_MMP", "FOOTBALL","{50,50,50,50,50,50,100}");
		
		
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_NET", "WARM","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_NET", "STD","{50,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_NET", "COOL","{60,50,50,50,50,50}");
		mStructure.setValue("CHTV_PIC_COLOR_TEMP_NET", "USER","{50,50,50,50,50,50}");		
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_NET", "MV","{50,50,50,50,50,50,100}");			
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_NET", "SPORTS","{50,50,60,50,50,50,100}");	
//		mStructure.setValue("CHTV_PIC_COLOR_TEMP_NET", "GAME","{50,50,60,50,50,50,100}");	
	//	mStructure.setValue("CHTV_PIC_COLOR_TEMP_NET", "FOOTBALL","{50,50,50,50,50,50,100}");
		
		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_STANDARD",
						"R_TABLE",
						"{0x00,0x0d,0x1a,0x27,0x34,0x41,0x4e,0x5b,0x69,0x76,0x83,0x90,0x9d,0xaa,0xb7,0xc5,0xd2,0xdf,0xec,0xf9,0x06,0x14,0x21,0x2e,0x3c,0x49,0x57,0x64,0x72,0x7f,0x8d,0x9b,0xa9,0xb6,0xc4,0xd2,0xe0,0xef,0xfd,0x0b,0x19,0x28,0x36,0x45,0x53,0x62,0x70,0x7f,0x8e,0x9c,0xab,0xba,0xc9,0xd7,0xe6,0xf5,0x04,0x13,0x22,0x31,0x40,0x4f,0x5e,0x6d,0x7d,0x8c,0x9b,0xaa,0xb9,0xc8,0xd8,0xe7,0xf6,0x05,0x15,0x24,0x33,0x43,0x52,0x61,0x71,0x80,0x8f,0x9e,0xae,0xbd,0xcc,0xdc,0xeb,0xfb,0x0a,0x19,0x29,0x38,0x48,0x57,0x67,0x76,0x85,0x95,0xa5,0xb4,0xc4,0xd3,0xe3,0xf2,0x02,0x12,0x21,0x31,0x40,0x50,0x60,0x6f,0x7f,0x8e,0x9e,0xad,0xbd,0xcd,0xdc,0xec,0xfb,0x0b,0x1a,0x2a,0x39,0x49,0x59,0x68,0x78,0x87,0x97,0xa6,0xb6,0xc5,0xd5,0xe4,0xf4,0x04,0x13,0x23,0x32,0x42,0x52,0x61,0x71,0x80,0x90,0x9f,0xaf,0xbf,0xce,0xde,0xee,0xfd,0x0d,0x1d,0x2c,0x3c,0x4c,0x5b,0x6b,0x7b,0x8a,0x9a,0xaa,0xb9,0xc9,0xd9,0xe8,0xf8,0x08,0x17,0x27,0x37,0x47,0x56,0x66,0x76,0x85,0x95,0xa5,0xb4,0xc4,0xd4,0xe4,0xf3,0x03,0x13,0x23,0x33,0x43,0x52,0x62,0x72,0x82,0x92,0xa2,0xb2,0xc2,0xd2,0xe2,0xf2,0x02,0x12,0x22,0x32,0x43,0x53,0x62,0x72,0x82,0x92,0xa2,0xb2,0xc2,0xd2,0xe2,0xf2,0x02,0x11,0x21,0x31,0x41,0x50,0x60,0x6f,0x7f,0x8f,0x9e,0xae,0xbd,0xcd,0xdc,0xec,0xfb,0x0b,0x1a,0x2a,0x3a,0x49,0x59,0x68,0x78,0x87,0x97,0xa6,0xb6,0xc6,0xd5,0xe5,0xf4,0x04,0x13,0x23,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
		
		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_STANDARD",
						"G_TABLE",
						"{0x00,0x0d,0x1a,0x27,0x35,0x42,0x4f,0x5c,0x6a,0x77,0x84,0x91,0x9f,0xac,0xb9,0xc7,0xd4,0xe1,0xef,0xfc,0x09,0x17,0x25,0x32,0x40,0x4d,0x5b,0x69,0x77,0x85,0x93,0xa1,0xb0,0xbe,0xcc,0xdb,0xe9,0xf8,0x07,0x16,0x25,0x34,0x43,0x52,0x61,0x70,0x7f,0x8e,0x9e,0xad,0xbc,0xcb,0xdb,0xea,0xf9,0x09,0x18,0x28,0x37,0x47,0x56,0x66,0x75,0x85,0x95,0xa4,0xb4,0xc3,0xd3,0xe3,0xf3,0x02,0x12,0x22,0x32,0x41,0x51,0x61,0x71,0x81,0x91,0xa0,0xb0,0xc0,0xd0,0xe0,0xef,0xff,0x0f,0x1f,0x2f,0x3f,0x4f,0x5f,0x6f,0x7f,0x8f,0x9e,0xae,0xbe,0xcf,0xdf,0xef,0xff,0x0f,0x1f,0x2f,0x3f,0x4f,0x5f,0x6f,0x7f,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x31,0x41,0x51,0x61,0x71,0x81,0x92,0xa2,0xb2,0xc2,0xd2,0xe3,0xf3,0x03,0x13,0x24,0x34,0x44,0x54,0x65,0x75,0x85,0x96,0xa6,0xb6,0xc6,0xd7,0xe7,0xf7,0x07,0x18,0x28,0x38,0x48,0x59,0x69,0x79,0x89,0x9a,0xaa,0xba,0xca,0xda,0xeb,0xfb,0x0b,0x1b,0x2c,0x3c,0x4c,0x5c,0x6d,0x7d,0x8d,0x9e,0xae,0xbe,0xce,0xdf,0xef,0xff,0x0f,0x20,0x30,0x40,0x51,0x61,0x71,0x82,0x92,0xa3,0xb3,0xc3,0xd4,0xe4,0xf5,0x05,0x16,0x26,0x37,0x47,0x58,0x68,0x79,0x89,0x9a,0xab,0xbb,0xcc,0xdc,0xed,0xfd,0x0e,0x1f,0x2f,0x40,0x51,0x61,0x72,0x83,0x93,0xa4,0xb5,0xc5,0xd6,0xe6,0xf7,0x08,0x18,0x29,0x3a,0x4a,0x5b,0x6b,0x7b,0x8c,0x9c,0xac,0xbd,0xcd,0xdd,0xed,0xfd,0x0d,0x1c,0x2c,0x3c,0x4c,0x5c,0x6b,0x7b,0x8b,0x9b,0xab,0xbb,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_STANDARD",
						"B_TABLE",
						"{0x00,0x0d,0x1a,0x27,0x35,0x42,0x4f,0x5c,0x6a,0x77,0x84,0x91,0x9f,0xac,0xb9,0xc7,0xd4,0xe1,0xef,0xfc,0x09,0x17,0x24,0x32,0x40,0x4d,0x5b,0x69,0x77,0x84,0x92,0xa0,0xaf,0xbd,0xcb,0xd9,0xe8,0xf6,0x05,0x13,0x22,0x30,0x3f,0x4e,0x5d,0x6c,0x7b,0x89,0x99,0xa8,0xb7,0xc6,0xd5,0xe4,0xf3,0x03,0x12,0x21,0x31,0x40,0x4f,0x5f,0x6e,0x7e,0x8e,0x9d,0xad,0xbc,0xcc,0xdc,0xec,0xfb,0x0b,0x1b,0x2b,0x3a,0x4a,0x5a,0x6a,0x7a,0x8a,0x99,0xa9,0xb9,0xc9,0xd9,0xe8,0xf8,0x08,0x18,0x28,0x38,0x48,0x58,0x68,0x77,0x88,0x98,0xa8,0xb8,0xc8,0xd8,0xe8,0xf8,0x09,0x19,0x29,0x39,0x49,0x5a,0x6a,0x7a,0x8b,0x9b,0xab,0xbb,0xcc,0xdc,0xec,0xfc,0x0d,0x1d,0x2d,0x3d,0x4d,0x5d,0x6d,0x7d,0x8e,0x9d,0xad,0xbd,0xcd,0xdd,0xed,0xfd,0x0d,0x1d,0x2d,0x3d,0x4c,0x5c,0x6c,0x7c,0x8d,0x9d,0xad,0xbd,0xcd,0xdd,0xee,0xfe,0x0e,0x1f,0x2f,0x3f,0x50,0x60,0x71,0x81,0x92,0xa2,0xb2,0xc3,0xd3,0xe4,0xf4,0x05,0x15,0x26,0x36,0x47,0x57,0x68,0x78,0x89,0x9a,0xaa,0xbb,0xcb,0xdc,0xec,0xfd,0x0e,0x1e,0x2f,0x40,0x50,0x61,0x72,0x82,0x93,0xa4,0xb4,0xc5,0xd5,0xe6,0xf7,0x07,0x18,0x29,0x3a,0x4a,0x5b,0x6c,0x7d,0x8e,0x9f,0xb0,0xc0,0xd1,0xe2,0xf4,0x05,0x16,0x27,0x38,0x49,0x5a,0x6b,0x7c,0x8d,0x9e,0xaf,0xc1,0xd1,0xe2,0xf3,0x04,0x15,0x26,0x37,0x48,0x5a,0x6b,0x7c,0x8e,0x9f,0xb1,0xc3,0xd5,0xe7,0xf9,0x0b,0x1e,0x30,0x43,0x55,0x68,0x7b,0x8e,0xa1,0xb4,0xc6,0xd9,0xec,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");

		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_SHOP",
						"R_TABLE",
						"{0x00,0x0f,0x1f,0x2f,0x3e,0x4e,0x5e,0x6d,0x7d,0x8d,0x9c,0xac,0xbc,0xcb,0xdb,0xeb,0xfb,0x0a,0x1a,0x2a,0x39,0x49,0x59,0x69,0x79,0x88,0x98,0xa8,0xb8,0xc7,0xd7,0xe7,0xf7,0x06,0x16,0x26,0x35,0x45,0x54,0x64,0x74,0x83,0x93,0xa2,0xb2,0xc1,0xd1,0xe0,0xf0,0xff,0x0e,0x1e,0x2d,0x3c,0x4c,0x5b,0x6a,0x7a,0x89,0x98,0xa8,0xb7,0xc7,0xd6,0xe6,0xf5,0x04,0x14,0x23,0x33,0x43,0x52,0x62,0x71,0x81,0x90,0xa0,0xb0,0xbf,0xcf,0xdf,0xee,0xfe,0x0d,0x1d,0x2c,0x3c,0x4c,0x5b,0x6b,0x7a,0x8a,0x99,0xa9,0xb8,0xc8,0xd8,0xe7,0xf7,0x06,0x16,0x25,0x35,0x44,0x54,0x64,0x73,0x83,0x92,0xa2,0xb1,0xc1,0xd1,0xe0,0xf0,0xff,0x0f,0x1e,0x2e,0x3e,0x4d,0x5d,0x6c,0x7c,0x8b,0x9b,0xaa,0xba,0xca,0xd9,0xe8,0xf8,0x07,0x17,0x26,0x36,0x45,0x55,0x64,0x74,0x83,0x92,0xa2,0xb1,0xc1,0xd0,0xdf,0xef,0xfe,0x0d,0x1d,0x2c,0x3c,0x4b,0x5a,0x6a,0x79,0x88,0x98,0xa7,0xb7,0xc6,0xd5,0xe5,0xf4,0x03,0x13,0x22,0x32,0x41,0x50,0x60,0x6f,0x7e,0x8e,0x9d,0xad,0xbc,0xcb,0xda,0xea,0xf9,0x08,0x18,0x27,0x36,0x46,0x55,0x64,0x74,0x83,0x92,0xa2,0xb1,0xc0,0xcf,0xdf,0xee,0xfd,0x0d,0x1c,0x2b,0x3b,0x4a,0x59,0x69,0x78,0x87,0x97,0xa6,0xb5,0xc4,0xd4,0xe3,0xf2,0x01,0x10,0x20,0x2f,0x3e,0x4d,0x5c,0x6b,0x7a,0x8a,0x99,0xa8,0xb7,0xc6,0xd4,0xe3,0xf2,0x01,0x10,0x1e,0x2d,0x3c,0x4a,0x59,0x67,0x76,0x84,0x92,0xa0,0xae,0xbc,0xca,0xd8,0xe6,0xf4,0x02,0x10,0x1e,0x2c,0x3a,0x48,0x56,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_SHOP",
						"G_TABLE",
						"{0x00,0x0f,0x1f,0x2f,0x3e,0x4e,0x5e,0x6d,0x7d,0x8d,0x9c,0xac,0xbc,0xcb,0xdb,0xeb,0xfb,0x0a,0x1a,0x2a,0x3a,0x49,0x59,0x69,0x79,0x89,0x98,0xa8,0xb8,0xc8,0xd8,0xe8,0xf8,0x07,0x17,0x27,0x37,0x47,0x56,0x66,0x76,0x86,0x96,0xa5,0xb5,0xc5,0xd5,0xe5,0xf5,0x04,0x14,0x24,0x34,0x44,0x53,0x63,0x73,0x83,0x93,0xa3,0xb2,0xc2,0xd2,0xe2,0xf2,0x01,0x11,0x21,0x31,0x40,0x50,0x60,0x6f,0x7f,0x8f,0x9f,0xae,0xbe,0xce,0xde,0xee,0xfd,0x0d,0x1d,0x2d,0x3d,0x4c,0x5c,0x6c,0x7c,0x8c,0x9b,0xab,0xbb,0xcb,0xdb,0xeb,0xfa,0x0a,0x1a,0x2a,0x39,0x49,0x59,0x68,0x78,0x88,0x98,0xa7,0xb7,0xc7,0xd7,0xe7,0xf6,0x06,0x16,0x26,0x36,0x45,0x55,0x65,0x75,0x85,0x94,0xa4,0xb4,0xc4,0xd4,0xe4,0xf3,0x03,0x13,0x23,0x32,0x42,0x52,0x61,0x71,0x81,0x91,0xa0,0xb0,0xc0,0xd0,0xe0,0xef,0xff,0x0f,0x1f,0x2f,0x3e,0x4e,0x5e,0x6e,0x7e,0x8d,0x9d,0xad,0xbd,0xcd,0xdd,0xec,0xfc,0x0c,0x1c,0x2b,0x3b,0x4b,0x5a,0x6a,0x7a,0x8a,0x99,0xa9,0xb9,0xc9,0xd9,0xe8,0xf8,0x08,0x18,0x28,0x37,0x47,0x57,0x67,0x77,0x86,0x96,0xa6,0xb6,0xc6,0xd6,0xe5,0xf5,0x05,0x15,0x24,0x34,0x44,0x53,0x63,0x73,0x83,0x92,0xa2,0xb2,0xc2,0xd2,0xe1,0xf1,0x01,0x11,0x21,0x30,0x40,0x50,0x60,0x70,0x7f,0x8f,0x9f,0xaf,0xbf,0xcf,0xde,0xee,0xfe,0x0e,0x1d,0x2d,0x3d,0x4c,0x5c,0x6c,0x7c,0x8b,0x9b,0xab,0xbb,0xcb,0xda,0xea,0xfa,0x0a,0x1a,0x2a,0x39,0x49,0x59,0x69,0x79,0x89,0x99,0xa9,0xb9,0xc9,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_SHOP",
						"B_TABLE",
						"{0x00,0x0d,0x1b,0x29,0x36,0x44,0x52,0x5f,0x6d,0x7b,0x88,0x96,0xa4,0xb1,0xbf,0xcd,0xdb,0xe8,0xf6,0x04,0x11,0x1f,0x2d,0x3b,0x48,0x56,0x64,0x72,0x7f,0x8d,0x9b,0xa9,0xb7,0xc4,0xd2,0xe0,0xee,0xfb,0x09,0x17,0x25,0x32,0x40,0x4e,0x5c,0x69,0x77,0x85,0x93,0xa0,0xae,0xbc,0xc9,0xd7,0xe5,0xf3,0x00,0x0e,0x1c,0x2a,0x37,0x45,0x53,0x61,0x6f,0x7c,0x8a,0x98,0xa6,0xb4,0xc2,0xd0,0xde,0xec,0xfa,0x08,0x16,0x24,0x32,0x40,0x4e,0x5b,0x69,0x77,0x85,0x93,0xa1,0xaf,0xbe,0xcc,0xda,0xe8,0xf6,0x04,0x12,0x20,0x2e,0x3b,0x49,0x57,0x65,0x73,0x81,0x8f,0x9d,0xab,0xb9,0xc7,0xd5,0xe3,0xf1,0xff,0x0e,0x1c,0x2a,0x38,0x46,0x54,0x62,0x70,0x7e,0x8c,0x9a,0xa8,0xb6,0xc4,0xd2,0xe0,0xee,0xfb,0x09,0x17,0x25,0x33,0x41,0x4f,0x5c,0x6a,0x78,0x86,0x94,0xa2,0xb0,0xbe,0xcc,0xd9,0xe8,0xf6,0x04,0x12,0x20,0x2e,0x3c,0x4a,0x58,0x66,0x74,0x82,0x90,0x9e,0xad,0xba,0xc8,0xd6,0xe4,0xf2,0x00,0x0e,0x1c,0x2a,0x38,0x46,0x54,0x62,0x70,0x7d,0x8c,0x9a,0xa8,0xb6,0xc4,0xd2,0xe0,0xee,0xfc,0x0b,0x19,0x27,0x35,0x43,0x51,0x5f,0x6e,0x7c,0x8a,0x98,0xa6,0xb4,0xc2,0xd0,0xde,0xec,0xfa,0x08,0x16,0x24,0x32,0x40,0x4f,0x5d,0x6b,0x79,0x87,0x96,0xa4,0xb2,0xc1,0xcf,0xdd,0xec,0xfa,0x09,0x17,0x25,0x34,0x42,0x50,0x5e,0x6d,0x7b,0x89,0x97,0xa6,0xb4,0xc2,0xd0,0xde,0xed,0xfb,0x09,0x18,0x26,0x34,0x42,0x51,0x5f,0x6e,0x7c,0x8a,0x99,0xa7,0xb6,0xc4,0xd2,0xe1,0xef,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");

		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_UMAX",
						"R_TABLE",
						"{0x00,0x0f,0x1e,0x2d,0x3c,0x4b,0x5a,0x69,0x78,0x87,0x96,0xa5,0xb4,0xc3,0xd2,0xe1,0xf1,0x00,0x0f,0x1e,0x2d,0x3c,0x4b,0x5a,0x69,0x79,0x88,0x97,0xa6,0xb5,0xc4,0xd3,0xe3,0xf2,0x01,0x10,0x1f,0x2e,0x3d,0x4c,0x5b,0x6b,0x7a,0x89,0x98,0xa7,0xb6,0xc5,0xd5,0xe4,0xf3,0x02,0x11,0x20,0x2f,0x3e,0x4e,0x5d,0x6c,0x7b,0x8a,0x99,0xa8,0xb7,0xc7,0xd6,0xe5,0xf4,0x03,0x12,0x21,0x30,0x3f,0x4e,0x5d,0x6c,0x7b,0x8a,0x99,0xa8,0xb8,0xc7,0xd6,0xe5,0xf4,0x03,0x12,0x21,0x30,0x3f,0x4e,0x5d,0x6c,0x7b,0x8a,0x99,0xa9,0xb7,0xc6,0xd5,0xe4,0xf3,0x02,0x11,0x20,0x2f,0x3e,0x4d,0x5c,0x6b,0x7a,0x89,0x98,0xa6,0xb5,0xc4,0xd3,0xe2,0xf1,0x00,0x0f,0x1e,0x2d,0x3c,0x4b,0x5a,0x69,0x78,0x87,0x95,0xa4,0xb3,0xc2,0xd1,0xdf,0xee,0xfd,0x0c,0x1b,0x29,0x38,0x47,0x56,0x65,0x74,0x82,0x91,0xa0,0xaf,0xbe,0xcd,0xdc,0xeb,0xfa,0x09,0x19,0x28,0x37,0x46,0x55,0x65,0x74,0x83,0x92,0xa2,0xb1,0xc1,0xd0,0xdf,0xef,0xfe,0x0e,0x1d,0x2d,0x3c,0x4c,0x5c,0x6b,0x7b,0x8a,0x9a,0xa9,0xb9,0xc8,0xd7,0xe7,0xf6,0x05,0x14,0x23,0x31,0x40,0x4f,0x5d,0x6b,0x79,0x87,0x95,0xa3,0xb1,0xbf,0xce,0xdc,0xeb,0xfa,0x09,0x19,0x29,0x3a,0x4a,0x5c,0x6d,0x7f,0x92,0xa4,0xb7,0xca,0xdd,0xf0,0x03,0x17,0x2a,0x3d,0x50,0x63,0x75,0x87,0x9a,0xac,0xbe,0xd0,0xe2,0xf4,0x06,0x18,0x2a,0x3c,0x4f,0x62,0x74,0x88,0x9b,0xae,0xc2,0xd6,0xea,0xff,0x13,0x28,0x3c,0x51,0x66,0x7a,0x8f,0xa4,0xb8,0xcd,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_UMAX",
						"G_TABLE",
						"{0x00,0x0f,0x1f,0x2f,0x3e,0x4e,0x5e,0x6d,0x7d,0x8d,0x9c,0xac,0xbc,0xcb,0xdb,0xeb,0xfb,0x0a,0x1a,0x2a,0x3a,0x49,0x59,0x69,0x79,0x89,0x98,0xa8,0xb8,0xc8,0xd8,0xe8,0xf8,0x07,0x17,0x27,0x37,0x47,0x56,0x66,0x76,0x86,0x96,0xa5,0xb5,0xc5,0xd5,0xe5,0xf5,0x04,0x14,0x24,0x34,0x44,0x53,0x63,0x73,0x83,0x93,0xa3,0xb2,0xc2,0xd2,0xe2,0xf2,0x01,0x11,0x21,0x31,0x40,0x50,0x60,0x6f,0x7f,0x8f,0x9f,0xae,0xbe,0xce,0xde,0xee,0xfd,0x0d,0x1d,0x2d,0x3d,0x4c,0x5c,0x6c,0x7c,0x8c,0x9b,0xab,0xbb,0xcb,0xdb,0xeb,0xfa,0x0a,0x1a,0x2a,0x39,0x49,0x59,0x68,0x78,0x88,0x98,0xa7,0xb7,0xc7,0xd7,0xe7,0xf6,0x06,0x16,0x26,0x36,0x45,0x55,0x65,0x75,0x85,0x94,0xa4,0xb4,0xc4,0xd4,0xe4,0xf3,0x03,0x13,0x23,0x32,0x42,0x52,0x62,0x71,0x81,0x91,0xa0,0xb0,0xc0,0xd0,0xe0,0xef,0xff,0x0f,0x1f,0x2f,0x3e,0x4e,0x5e,0x6e,0x7e,0x8d,0x9d,0xad,0xbd,0xcd,0xdd,0xec,0xfc,0x0c,0x1c,0x2b,0x3b,0x4b,0x5b,0x6a,0x7a,0x8a,0x99,0xa9,0xb9,0xc9,0xd9,0xe8,0xf8,0x08,0x18,0x28,0x37,0x47,0x57,0x67,0x77,0x86,0x96,0xa6,0xb6,0xc6,0xd6,0xe5,0xf5,0x05,0x15,0x24,0x34,0x44,0x54,0x63,0x73,0x83,0x92,0xa2,0xb2,0xc2,0xd2,0xe1,0xf1,0x01,0x11,0x20,0x30,0x40,0x50,0x60,0x70,0x7f,0x8f,0x9f,0xaf,0xbf,0xcf,0xde,0xee,0xfe,0x0e,0x1e,0x2d,0x3d,0x4d,0x5d,0x6d,0x7c,0x8c,0x9c,0xac,0xbc,0xcc,0xdb,0xeb,0xfb,0x0b,0x1b,0x2a,0x3a,0x4a,0x5a,0x6a,0x79,0x89,0x99,0xa9,0xb9,0xc9,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_UMAX",
						"B_TABLE",
						"{0x00,0x10,0x21,0x32,0x42,0x53,0x64,0x75,0x85,0x96,0xa7,0xb8,0xc8,0xd9,0xea,0xfb,0x0c,0x1c,0x2d,0x3e,0x4f,0x5f,0x70,0x81,0x92,0xa3,0xb3,0xc4,0xd5,0xe6,0xf6,0x07,0x18,0x28,0x39,0x49,0x5a,0x6a,0x7b,0x8b,0x9c,0xac,0xbd,0xcd,0xde,0xef,0xff,0x10,0x21,0x31,0x42,0x53,0x64,0x74,0x85,0x96,0xa7,0xb8,0xc9,0xda,0xea,0xfb,0x0c,0x1d,0x2e,0x3e,0x4f,0x5f,0x70,0x80,0x91,0xa1,0xb2,0xc2,0xd3,0xe3,0xf4,0x05,0x15,0x26,0x37,0x47,0x58,0x69,0x7a,0x8b,0x9c,0xad,0xbe,0xcf,0xe0,0xf1,0x02,0x13,0x24,0x35,0x46,0x56,0x67,0x78,0x89,0x99,0xaa,0xbb,0xcc,0xdc,0xed,0xfe,0x0e,0x1f,0x30,0x41,0x52,0x62,0x73,0x84,0x95,0xa6,0xb7,0xc8,0xd9,0xea,0xfb,0x0c,0x1c,0x2d,0x3e,0x4f,0x60,0x70,0x81,0x91,0xa2,0xb2,0xc3,0xd3,0xe4,0xf4,0x05,0x15,0x26,0x36,0x46,0x57,0x68,0x78,0x89,0x99,0xaa,0xbb,0xcb,0xdc,0xed,0xfe,0x0f,0x20,0x30,0x41,0x52,0x63,0x75,0x86,0x97,0xa8,0xb9,0xca,0xdb,0xed,0xfe,0x0f,0x20,0x32,0x43,0x54,0x65,0x76,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff,0x10,0x22,0x33,0x44,0x56,0x67,0x78,0x8a,0x9c,0xad,0xbf,0xd1,0xe2,0xf4,0x06,0x17,0x29,0x3a,0x4b,0x5c,0x6c,0x7c,0x8c,0x9b,0xab,0xb9,0xc7,0xd5,0xe3,0xf0,0xfd,0x09,0x16,0x22,0x2e,0x3a,0x46,0x51,0x5d,0x69,0x75,0x80,0x8c,0x98,0xa4,0xb0,0xbc,0xc8,0xd4,0xe0,0xed,0xf9,0x05,0x11,0x1e,0x2a,0x37,0x43,0x4f,0x5c,0x68,0x75,0x81,0x8e,0x9a,0xa7,0xb3,0xc0,0xcc,0xd9,0xe5,0xf2,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");

		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_HDR",
						"R_TABLE",
						"{0x00,0x06,0x0b,0x0f,0x13,0x18,0x1c,0x20,0x24,0x29,0x2d,0x32,0x36,0x3b,0x40,0x45,0x49,0x4e,0x53,0x59,0x5e,0x63,0x69,0x6e,0x74,0x7a,0x7f,0x85,0x8b,0x91,0x98,0x9e,0xa5,0xab,0xb2,0xb9,0xc0,0xc7,0xce,0xd5,0xdc,0xe4,0xec,0xf3,0xfb,0x03,0x0b,0x14,0x1c,0x25,0x2d,0x36,0x3f,0x49,0x52,0x5b,0x65,0x6f,0x79,0x83,0x8d,0x97,0xa2,0xac,0xb7,0xc2,0xce,0xd9,0xe5,0xf0,0xfc,0x09,0x15,0x21,0x2e,0x3b,0x48,0x56,0x63,0x71,0x7f,0x8d,0x9b,0xaa,0xb9,0xc8,0xd7,0xe7,0xf6,0x06,0x17,0x27,0x38,0x49,0x5a,0x6c,0x7e,0x90,0xa2,0xb5,0xc7,0xdb,0xee,0x02,0x16,0x2a,0x3f,0x54,0x69,0x7f,0x95,0xab,0xc2,0xd9,0xf0,0x08,0x20,0x38,0x51,0x6a,0x84,0x9e,0xb8,0xd3,0xee,0x09,0x25,0x42,0x5e,0x7c,0x99,0xb7,0xd6,0xf5,0x15,0x35,0x55,0x76,0x97,0xb9,0xdc,0xff,0x22,0x47,0x6b,0x90,0xb8,0xdc,0xfd,0x1e,0x43,0x68,0x8d,0xad,0xcd,0xf2,0x12,0x35,0x55,0x75,0x9a,0xbd,0xe1,0x05,0x28,0x4c,0x6a,0x84,0xa5,0xc3,0xdd,0xf7,0x15,0x2f,0x4f,0x69,0x8d,0xab,0xc5,0xe6,0x04,0x1e,0x3f,0x59,0x77,0x91,0xaf,0xc9,0xe7,0x01,0x1f,0x3a,0x54,0x6a,0x82,0x9f,0xb7,0xdb,0xef,0xff,0x09,0x17,0x2b,0x3b,0x4f,0x5b,0x6b,0x77,0x87,0x93,0x9b,0xa7,0xaf,0xb7,0xbf,0xc7,0xcb,0xd4,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_HDR",
						"G_TABLE",
						"{0x00,0x06,0x0b,0x0f,0x13,0x18,0x1c,0x20,0x24,0x29,0x2d,0x32,0x36,0x3b,0x40,0x45,0x49,0x4e,0x53,0x59,0x5e,0x63,0x69,0x6e,0x74,0x7a,0x7f,0x85,0x8b,0x91,0x98,0x9e,0xa5,0xab,0xb2,0xb9,0xc0,0xc7,0xce,0xd5,0xdc,0xe4,0xec,0xf3,0xfb,0x03,0x0b,0x14,0x1c,0x25,0x2d,0x36,0x3f,0x49,0x52,0x5b,0x65,0x6f,0x79,0x83,0x8d,0x97,0xa2,0xac,0xb7,0xc2,0xce,0xd9,0xe5,0xf0,0xfc,0x09,0x15,0x21,0x2e,0x3b,0x48,0x56,0x63,0x71,0x7f,0x8d,0x9b,0xaa,0xb9,0xc8,0xd7,0xe7,0xf6,0x06,0x17,0x27,0x38,0x49,0x5a,0x6c,0x7e,0x90,0xa2,0xb5,0xc7,0xdb,0xee,0x02,0x16,0x2a,0x3f,0x54,0x69,0x7f,0x95,0xab,0xc2,0xd9,0xf0,0x08,0x20,0x38,0x51,0x6a,0x84,0x9e,0xb8,0xd3,0xee,0x09,0x25,0x42,0x5e,0x7c,0x99,0xb7,0xd6,0xf5,0x15,0x35,0x55,0x76,0x97,0xb9,0xdc,0xff,0x22,0x47,0x6b,0x90,0xb8,0xdc,0xfd,0x1e,0x43,0x68,0x8d,0xad,0xcd,0xf2,0x12,0x35,0x55,0x75,0x9a,0xbd,0xe1,0x05,0x28,0x4c,0x6a,0x84,0xa5,0xc3,0xdd,0xf7,0x15,0x2f,0x4f,0x69,0x8d,0xab,0xc5,0xe6,0x04,0x1e,0x3f,0x59,0x77,0x91,0xaf,0xc9,0xe7,0x01,0x1f,0x3a,0x54,0x6a,0x82,0x9f,0xb7,0xdb,0xef,0xff,0x09,0x17,0x2b,0x3b,0x4f,0x5b,0x6b,0x77,0x87,0x93,0x9b,0xa7,0xaf,0xb7,0xbf,0xc7,0xcb,0xd4,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_HDR",
						"B_TABLE",
						"{0x00,0x06,0x0b,0x0f,0x13,0x18,0x1c,0x20,0x24,0x29,0x2d,0x32,0x36,0x3b,0x40,0x45,0x49,0x4e,0x53,0x59,0x5e,0x63,0x69,0x6e,0x74,0x7a,0x7f,0x85,0x8b,0x91,0x98,0x9e,0xa5,0xab,0xb2,0xb9,0xc0,0xc7,0xce,0xd5,0xdc,0xe4,0xec,0xf3,0xfb,0x03,0x0b,0x14,0x1c,0x25,0x2d,0x36,0x3f,0x49,0x52,0x5b,0x65,0x6f,0x79,0x83,0x8d,0x97,0xa2,0xac,0xb7,0xc2,0xce,0xd9,0xe5,0xf0,0xfc,0x09,0x15,0x21,0x2e,0x3b,0x48,0x56,0x63,0x71,0x7f,0x8d,0x9b,0xaa,0xb9,0xc8,0xd7,0xe7,0xf6,0x06,0x17,0x27,0x38,0x49,0x5a,0x6c,0x7e,0x90,0xa2,0xb5,0xc7,0xdb,0xee,0x02,0x16,0x2a,0x3f,0x54,0x69,0x7f,0x95,0xab,0xc2,0xd9,0xf0,0x08,0x20,0x38,0x51,0x6a,0x84,0x9e,0xb8,0xd3,0xee,0x09,0x25,0x42,0x5e,0x7c,0x99,0xb7,0xd6,0xf5,0x15,0x35,0x55,0x76,0x97,0xb9,0xdc,0xff,0x22,0x47,0x6b,0x90,0xb8,0xdc,0xfd,0x1e,0x43,0x68,0x8d,0xad,0xcd,0xf2,0x12,0x35,0x55,0x75,0x9a,0xbd,0xe1,0x05,0x28,0x4c,0x6a,0x84,0xa5,0xc3,0xdd,0xf7,0x15,0x2f,0x4f,0x69,0x8d,0xab,0xc5,0xe6,0x04,0x1e,0x3f,0x59,0x77,0x91,0xaf,0xc9,0xe7,0x01,0x1f,0x3a,0x54,0x6a,0x82,0x9f,0xb7,0xdb,0xef,0xff,0x09,0x17,0x2b,0x3b,0x4f,0x5b,0x6b,0x77,0x87,0x93,0x9b,0xa7,0xaf,0xb7,0xbf,0xc7,0xcb,0xd4,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");

		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_4",
						"R_TABLE",
						"{0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_4",
						"G_TABLE",
						"{0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_4",
						"B_TABLE",
						"{0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");

		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_5",
						"R_TABLE",
						"{0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_5",
						"G_TABLE",
						"{0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
		mStructure
				.setValue(
						"CHTV_PIC_GAMMA_TABLE_5",
						"B_TABLE",
						"{0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
		if (needShopValue = true) {
			mStructure.setValue("CHTV_PICTUREMODE_SETTING", "STANDARD", "{100,50,50,50,0,100,1,2}");
			mStructure.setValue("CHTV_PICTUREMODE_SETTING", "VIVID", "{100,50,65,60,0,100,2,3}");
			mStructure.setValue("CHTV_PICTUREMODE_SETTING", "HOME", "{100,50,65,60,0,65,1,3}");
			mStructure.setValue("CHTV_PICTUREMODE_SETTING", "MILD", "{50,50,35,40,0,30,1,1}");
			mStructure.setValue("CHTV_PICTUREMODE_SETTING", "USER", "{100,50,50,50,0,100,1,4}");

	
			mStructure.setValue("CHTV_PICTUREMODE_SETTING_SHOP", "STANDARD", "{100,50,50,50,0,100}");
			mStructure.setValue("CHTV_PICTUREMODE_SETTING_SHOP", "VIVID", "{100,50,65,60,0,100}");
			mStructure.setValue("CHTV_PICTUREMODE_SETTING_SHOP", "HOME", "{100,50,65,60,0,65}");
			mStructure.setValue("CHTV_PICTUREMODE_SETTING_SHOP", "MILD", "{50,50,35,40,0,30}");
			mStructure.setValue("CHTV_PICTUREMODE_SETTING_SHOP", "USER", "{100,50,50,50,0,100}");
		}
//		if(SystemProperties.get("ro.product.brand", "CHANGHONG").equalsIgnoreCase("BenQ")){
//			mStructure
//			.setValue(
//					"CHTV_LIGHTSENSOR_BENQ",
//					"LIGHTSENSOR_LINEAR",
//					"{12,25,55,110,220}");
//		}
//		mStructure
//				.setValue(
//				"CHTV_PIC_GAMMA_TABLE_8500K_10000K",
//				"R_TABLE",
//				"{0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
//		mStructure
//				.setValue(
//				"CHTV_PIC_GAMMA_TABLE_8500K_10000K",
//				"G_TABLE",
//				"{0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
//		mStructure
//				.setValue(
//				"CHTV_PIC_GAMMA_TABLE_8500K_10000K",
//				"B_TABLE",
//				"{0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
//
//		mStructure
//				.setValue(
//				"CHTV_PIC_GAMMA_TABLE_11500K_13000K",
//				"R_TABLE",
//				"{0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
//		mStructure
//				.setValue(
//				"CHTV_PIC_GAMMA_TABLE_11500K_13000K",
//				"G_TABLE",
//				"{0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");
//		mStructure
//				.setValue(
//				"CHTV_PIC_GAMMA_TABLE_11500K_13000K",
//				"B_TABLE",
//				"{0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}");

	}
	
	private EnumInputSourceType getSourceType(String sourceName){
		if(sourceName.equalsIgnoreCase("TV")){
			return EnumInputSourceType.E_ATV;
		} else if(sourceName.equalsIgnoreCase("Composite")){
			return EnumInputSourceType.E_SVIDEO;
		} else if(sourceName.equalsIgnoreCase("Component")){
			return EnumInputSourceType.E_YPBPR;
		} else if(sourceName.equalsIgnoreCase("VGA")){
			return EnumInputSourceType.E_VGA;
		} else if(sourceName.equalsIgnoreCase("HDMI 1") 
				|| sourceName.equalsIgnoreCase("HDMI 2")
				|| sourceName.equalsIgnoreCase("HDMI 3")){
			return EnumInputSourceType.E_HDMI;
		} else {
			return EnumInputSourceType.E_NONE;
		}
	}
	
	private int getSourceIDByName(String sourceName){
		for(int i = 0; i < inputList.size(); i++){
			if(sourceName.equals(inputList.get(i).getSourceName())){
				return inputList.get(i).getId();
			}
		}
		return -1;
	}
	
private void initSourceName(){
		
		int compositeNum = 0;
        int size = MtkTvInputSource.getInstance().getInputSourceTotalNumber();
        
        for (int i = 0; i < size; i++){
            MtkTvInputSource.InputSourceRecord record = new MtkTvInputSource.InputSourceRecord();
            MtkTvInputSource.getInstance().getInputSourceRecbyidx(i, record);

            inputList.add(record);
            String sourceTypeName;
            sourceTypeName = record.getInputType().name();
            Log.i(TAG, "lhtest i= "+i+"  sourceTypeName="+sourceTypeName); 
            
            if (TextUtils.isEmpty(sourceTypeName)) {
                continue;
            } else {
                
                    if (sourceTypeName.equalsIgnoreCase("TV")) {
                    	if(mUiSourceList.contains("DTV")){
                    	    mUiSourceList.add("ATV");
                    	    sourceMap.put("ATV", TVUri);
                        } else {
                        	 mUiSourceList.add("DTV");
                     	     sourceMap.put("DTV", TVUri);
                        }
//                    	mUiSourceList.add("TV");
//                	    sourceMap.put("TV", TVUri);
                    } else if (sourceTypeName.equalsIgnoreCase("COMPOSITE")) {
                        compositeNum = record.getInternalIdx();
                        if (compositeNum > 0) {// modify string for idx=0
                            if (compositeNum == 1) {
                                mUiSourceList.set(mUiSourceList.size() - 1,
                                        "Composite " + compositeNum);
                            }
                            mUiSourceList
                                    .add("Composite " + (compositeNum + 1));
                        } else {
                            mUiSourceList.add("Composite");
                            sourceMap.put("Composite",CompositeUri);
                        }
                    } else if (sourceTypeName.equalsIgnoreCase("COMPONENT")) {
                        mUiSourceList.add("Component");
                        sourceMap.put("Component", ComponentUri);
                    } else if (sourceTypeName.equalsIgnoreCase("VGA")) {
                        mUiSourceList.add("VGA");
                        sourceMap.put("VGA", VgaUri);
                    } else if (sourceTypeName.equalsIgnoreCase("HDMI")) {
//                        if ((record.getInternalIdx() + 1) == mTvInputSource.getMhlPortNum()) {// mTvInputSource.getMhlPortNum()
//                            mUiSourceList.add("HDMI "
//                                    + (record.getInternalIdx() + 1) + " / MHL");
//                        } else {
                            mUiSourceList.add("HDMI "
                                    + (record.getInternalIdx() + 1));
//                        }
                          if(record.getInternalIdx() + 1 == 1 ){
                        	  sourceMap.put("HDMI 1", HDMI1Uri);
                          } else if(record.getInternalIdx() + 1 == 2){
                        	  sourceMap.put("HDMI 2", HDMI2Uri);
                          } else if(record.getInternalIdx() + 1 == 3){
                        	  sourceMap.put("HDMI 3", HDMI3Uri);
                          }
                    } else if (sourceTypeName.equalsIgnoreCase("RESERVED")) {
                        mUiSourceList.add("RESERVED");
                    } else if (sourceTypeName.equalsIgnoreCase("SCART")) {
                        mUiSourceList.add("SCART");
                    } else if (sourceTypeName.equalsIgnoreCase("SVIDEO")) {
                        mUiSourceList.add("SVIDEO");
                    }
                }
        }
	}

private EnumInputSourceType getCurrentInputSourceType() {
    int inputSourceIndex = MtkTvFApiInputSource.getInstance().getCurrentInputSource();
    EnumInputSourceType inputSourceType = EnumInputSourceType.E_OTHERS;
    switch (inputSourceIndex) {
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_VGA:
        inputSourceType = EnumInputSourceType.E_VGA;
        break;
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_ATV:
        inputSourceType = EnumInputSourceType.E_ATV;
        break;
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_AV_1:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_AV_2:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_AV_3:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_AV_4:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_AV_5:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_AV_6:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_AV_7:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_AV_8:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_AV_MAX:
        inputSourceType = EnumInputSourceType.E_YPBPR;
        break;
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_SVIDEO_1:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_SVIDEO_2:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_SVIDEO_3:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_SVIDEO_4:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_SVIDEO_MAX:
        inputSourceType = EnumInputSourceType.E_SVIDEO;
        break;
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_COMPONENT_1:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_COMPONENT_2:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_COMPONENT_3:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_COMPONENT_MAX:
        inputSourceType = EnumInputSourceType.E_CVBS;
        break;
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_SCART_1:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_SCART_2:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_SCART_MAX:
        inputSourceType = EnumInputSourceType.E_SCART;
        break;
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_HDMI_1:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_HDMI_2:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_HDMI_3:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_HDMI_4:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_HDMI_MAX:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_DVI_1:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_DVI_2:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_DVI_3:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_DVI_4:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_DVI_MAX:
        inputSourceType = EnumInputSourceType.E_HDMI;
        break;
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_DTV:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_DTV_2:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_DTV_3:
        inputSourceType = EnumInputSourceType.E_DTV;
        break;
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_STORAGE:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_STORAGE_2:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_KTV:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_JPEG:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_SCALER_OP:
    case MtkTvFApiInpsrcEnm.E_MTK_TV_FAPI_INPSRC_TYPE_MAX:
        inputSourceType = EnumInputSourceType.E_OTHERS;
        break;
    }
    return inputSourceType;
}
}
